- $(‘#my_tag’).addClass(‘my_class’); // Applies my_class to my_tag (notice we don’t use the dot for the class name
- $(‘#my_tag’).removeClass(‘my_class’); // The opposite
- $(‘#my_tag’).toggleClass(‘my_class’); // Adds the class if it wasn’t there, remove it if it was
- the .css() Jquery function lets you either read the current CSS applied to a tag, or modify it:
- var bgColor = $(‘#my_tag’).css(‘background-color’); // Reads bg color information into bgColor
- $(‘#my_tag’).css(‘background-color’,’#FFFFFF’); // Sets the background color of my_tag, you can change multiple CSS properties if you specified the css() argument in between { }
Categories