源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jQuery 添加样式属性的优先级别方法(推荐)

  • 时间:2020-01-20 19:04 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jQuery 添加样式属性的优先级别方法(推荐)
[b]jQuery类中添加多个属性[/b]
$('#five .a')
.css({
  color:'blue',
  border:'2px solid green',
  background:'blue'
});
[b]jQuer为元素添加类[/b]
$('#five .a')
.addClass('funny');
[b]HTML code[/b]
 <style>
.funny{
  font-size: 21px;
  background-color: gray ;
  padding: 10px;
  color: yellow ;
}
 </style>
<div id="five">
  <div class="a">A</div>
</div>
[img]http://files.jb51.net/file_images/article/201706/2017060808044910.png[/img] 可以看到jQuery类中添加多个属性渲染效果是以内嵌样式出现的。 而jQuer为元素添加的类没有内嵌样式的优先级高 可以看到渲染效果中没有funny的background-color: gray ;和color: yellow ;属性。 [img]http://files.jb51.net/file_images/article/201706/2017060808044911.png[/img] 以上这篇jQuery 添加样式属性的优先级别方法(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部