Home > Web Front-end > JS Tutorial > Jquery css function usage (determining whether a tag has a certain attribute)_jquery

Jquery css function usage (determining whether a tag has a certain attribute)_jquery

WBOY
Release: 2016-05-16 18:06:22
Original
1249 people have browsed it

Determine whether a layer is hidden:

Copy code The code is as follows:
$("#id").css ("display")=="none" ;


On all matching elements, set the value of a style attribute:

Copy the code The code is as follows:
$("p").css("color","red");


An object of name/value pairs set as the style properties of all matching elements.
This is the best way to set a large number of style attributes on all matching elements


Copy code The code is as follows:
$("p").css({ color: "#ff0011", background: "blue" });



If If the attribute name contains "-", quotation marks must be used:

Copy code The code is as follows:
$("p").css({ "margin-left": "10px", "background-color": "blue" });
Related labels:
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