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' });
jQuer adds classes to elements
$('#five .a') .addClass('funny');
HTML code
A
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!