jq Method to modify css attributes: 1. Set the value for the given CSS attribute of all matching elements through "css(name,value)"; 2. Use "css({properties})" to set the value for the matching element A series of CSS attribute setting values; 3. Return the value of the specified CSS attribute through "css(name)".
The operating environment of this article: windows7 system, jquery1.2.6&&CSS3 version, Dell G3 computer.
jq How to modify css attributes?
jQuery modifies css attributes:
jQuery has three types of CSS operations Important functions:
$(selector).css(name,value) $(selector).css({properties}) $(selector).css(name)
Function css(name,value) Sets the value for the given CSS property of all matching elements:
Example
$(selector).css(name,value) $("p").css("background-color","red");
Function css({properties}) Simultaneously set values for a series of CSS properties of all matching elements:
Example
$(selector).css({properties}) $("p").css({"background-color":"red","font-size":"200%"});
Function css(name) returns the value of the specified CSS property:
Example
$(selector).css(name) $(this).css("background-color");
Recommended learning: "css video tutorial", "jquery video tutorial"
The above is the detailed content of How to modify css attributes in jq. For more information, please follow other related articles on the PHP Chinese website!