本文实例讲述了jquery给多个不同元素添加class样式的方法。分享给大家供大家参考。具体分析如下:
jquery可以通过addclass()方法给多个不同的html元素同时添加相同的class
<!doctype html> <html> <head> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("h1,h2,p").addclass("blue"); $("p").addclass("important"); }); }); </script> <style type="text/css"> .important { font-weight:bold; font-size:xx-large; } .blue { color:blue; } </style> </head> <body> <h1>heading 1</h1> <h2>heading 2</h2> <p>this is a paragraph.</p> <p>this is another paragraph.</p> <p>this is some important text!</p> <br> <button>add classes to elements</button> </body> </html>
如对本文有疑问, 点击进行留言回复!!
轻松解决 org.apache.taglibs.standard.tlv.JstlCoreTLV 困惑
vert实践五——Json?Protocol Buffer?FlatBuffers?
[基于tensorflow的人脸检测] 基于神经网络的人脸检测8——验证训练好的神经网络
selenium + ajax抓取英雄联盟全部英雄的详细信息及多线程保存全部皮肤图片到本地
网友评论