See the code below to see how to use ToggleClass in jQuery:
//Toggle class allows you to add or remove a class
//from an element depending on the presence of that
//class. Where some developers would use:
a.hasClass('blueButton') ? a.removeClass('blueButton') : a.addClass('blueButton');
//toggleClass allows you to easily do this using
a.toggleClass('blueButton');
Related posts:
- How to clone an element in jQuery See the code example below to clone an element when...
- Load jQuery from Google Code for caching! Why use your own copy of jQuery, use the one...
- Use jQuery in WordPress: wp_enqueue_script Great tutorial on the use of jQuery within WordPress: Click...
- Upload images without problems using jQuery! Using a little bit of jQuery we can upload images...
- 5 articles to improve your jQuery skills! jQuery 1.4 API Cheat Sheet Complete cheat sgeet of the...
Related posts brought to you by Yet Another Related Posts Plugin.