by Dave Reeder
24. September 2009 21:28
The .addClass method will add a CSS class to the selected element on a page. For example, imagine we have a navigaton bar which contains our page links and the homepage link has an ID of "navHome". We can use jQuery to select the link in our nav and add the class very easily:
<script type="text/javascript">
$(document).ready(function() {
$('#navHome').addClass('current');
});
</script>
Obviously this is just a simple example of the .addClass method, it can be used for anything you require.