Skip to content
Advertisement

Add class on div using foreach if else Laravel

I have 5 items ( 3 items on first row & 2 items on 2nd row ) that loads something like this

enter image description here

Here’s my sample blade code

JavaScript

But what I’m trying to do is something like this

enter image description here

By doing this I need to add a class named as ‘mid’ on this location

JavaScript

Tried to use something like this

JavaScript

But it doesn’t give me the right output like what I expected.

I just want to add class ‘mid’ for every 2nd item of the rows

Advertisement

Answer

A simple solution :

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement