Home  >  Article  >  Web Front-end  >  How to modify the style attribute in jquery

How to modify the style attribute in jquery

青灯夜游
青灯夜游Original
2021-11-12 16:45:4718795browse

You can use the attr() method in jquery to modify the style attribute. This method sets the attribute value of the selected element. The syntax is "$(selector).attr("style","inline style code")" or "$(selector).attr({"style":"style code"})".

How to modify the style attribute in jquery

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

In jquery, you can use the attr() method to modify the style attribute of an element.

attr() method can set the attribute value of the selected element. Depending on the parameters of the method, the way it works is also different.

Grammar:

$(selector).attr(attribute,value)
$(selector).attr({attribute:value})

Example:










hello

How to modify the style attribute in jquery

Related video tutorial recommendation: jQuery tutorial( video)

The above is the detailed content of How to modify the style attribute in jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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