Target any css element! use jQuery

So, I hadn’t thought of doing this until today, but with a small snippet of jQuery you can target just about any html element that you want.

Use this to add a simple target-able class

$(‘div #minitwitter-widget-2’).addClass(‘clearfix’);

You can even add a counter to a list of items by using this

$( “#metaslider_4 ul li” ).addClass(function( index ) {
return “slide-” + index;
});

Given an unordered list with two <li> elements, this example adds the class “item-0” to the first <li> and “item-1” to the second.

Use this url as a reference http://api.jquery.com/addClass/

Leave a Reply