Home > Web Front-end > Front-end Q&A > How to modify css attributes in jq

How to modify css attributes in jq

藏色散人
Release: 2021-11-17 15:45:14
Original
6737 people have browsed it

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)".

How to modify css attributes in jq

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)
Copy after login

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");
Copy after login

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%"});
Copy after login

Function css(name) returns the value of the specified CSS property:

Example

$(selector).css(name)
$(this).css("background-color");
Copy after login

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!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template