Sharing the priority method of adding style attributes in jQuery

小云云
Release: 2018-01-10 10:24:10
Original
1224 people have browsed it

This article mainly brings you a priority method for adding style attributes in jQuery (recommended). The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look, I hope it can help everyone.

Add multiple attributes to the jQuery class

$('#five .a') .css({ color:'blue', border:'2px solid green', background:'blue' });
Copy after login

jQuer adds classes to elements

$('#five .a') .addClass('funny');
Copy after login

HTML code

 

A

Copy after login

You can see that the rendering effect of adding multiple attributes to the jQuery class appears as an inline style.

The class added by jQuer to the element does not have a high priority as the inline style.

You can see that there are no funny background-color: gray; and color: yellow; attributes in the rendering effect.

Related recommendations;

Summary of examples of methods for obtaining various CSS style attributes in native javascript

jQuery Add priority level of style attributes

HTML Basics (5)-css style sheet style attribute format and layout

The above is the detailed content of Sharing the priority method of adding style attributes in jQuery. For more information, please follow other related articles on the PHP Chinese website!

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!