jQuery类中添加多个属性

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

jQuer为元素添加类

$('#five .a')
.addClass('funny');

HTML code

 <style>
.funny{
	font-size: 21px;
	background-color: gray ;
	padding: 10px;
	color: yellow ;
}
 </style>
<div >
    <div class="a">A</div>
</div>

jQuery 添加样式属性的优先级别

可以看到jQuery类中添加多个属性渲染效果是以内嵌样式出现的。

而jQuer为元素添加的类没有内嵌样式的优先级高

可以看到渲染效果中没有funny的background-color: gray ;color: yellow ;属性。

jQuery 添加样式属性的优先级别

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2021-12-26
  • 2022-12-23
猜你喜欢
  • 2022-01-29
  • 2022-01-02
  • 2021-08-21
  • 2021-12-17
  • 2022-12-23
相关资源
相似解决方案