Add a last class to every Fourth wordpress post using javascript


Javascript

jQuery(document).ready(function() {
var i = 1;
jQuery('.portfolio').each(function() {
if(i++ % 4 == 0)
jQuery(this).addClass('last');
});

});

CSS

.last { clear:both;}

 

Advertisements

3 thoughts on “Add a last class to every Fourth wordpress post using javascript

  1. Hi there this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding know-how so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s