Tutorial by Examples

Setting only one style: $('#target-element').css('color', '#000000'); Setting multiple styles at the same time: $('#target-element').css({ 'color': '#000000', 'font-size': '12pt', 'float': 'left', });
To get an element's CSS property you can use the .css(propertyName) method: var color = $('#element').css('color'); var fontSize = $('#element').css('font-size');
Numeric CSS properties can be incremented and decremented with the += and -= syntax, respectively, using the .css() method: // Increment using the += syntax $("#target-element").css("font-size", "+=10"); // You can also specify the unit to increment by $...
CSS Getter The .css() getter function can be applied to every DOM element on the page like the following: // Rendered width in px as a string. ex: `150px` // Notice the `as a string` designation - if you require a true integer, // refer to `$.width()` method $("body").css("width...

Page 1 of 1