jQuery类中添加多个属性
复制代码
1
2
3
4
5
6$('#five .a') .css({ color:'blue', border:'2px solid green', background:'blue' });
jQuer为元素添加类
复制代码
1
2$('#five .a') .addClass('funny');
HTML code
复制代码
1
2
3
4
5
6
7
8
9
10
11<style> .funny{ font-size: 21px; background-color: gray ; padding: 10px; color: yellow ; } </style> <div id="five"> <div class="a">A</div> </div>
可以看到jQuery类中添加多个属性渲染效果是以内嵌样式出现的。
而jQuer为元素添加的类没有内嵌样式的优先级高
可以看到渲染效果中没有funny的background-color: gray ;和color: yellow ;属性。
以上这篇jQuery 添加样式属性的优先级别方法(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
最后
以上就是魔幻未来最近收集整理的关于jQuery 添加样式属性的优先级别方法(推荐)的全部内容,更多相关jQuery内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复