1) $() function is actually a factory for jQuery object. It is the object encapsulates zero or more DOM dlements.
2) .addClass() and .removeClass()
They are fairly self-explanatory.
Its only parameter is the name of the class to add or remove.
Here are two samples.


Sample 1.

$(document).ready(function() {
$('.poem').addClass('emphasized');
});</div>
It is the function to add class 'emphasized' on the class 'poem'.
Sample 2.
<div class="scode">$(document).ready(function() {
$('span:contains(language)').addClass('emphasized');
});

This sample try to find the span which contains “language”, and add a class ’emphasized’ on these span.

David Yin

David is a blogger, geek, and web developer — founder of FreeInOutBoard.com. If you like his post, you can say thank you here

Leave a Reply

Your email address will not be published. Required fields are marked *