abstract:<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>jQuery练习</title> <style> .dex { font-size:35px; color:cornflowerblue;
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jQuery练习</title> <style> .dex { font-size:35px; color:cornflowerblue; } </style> <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ // $("p").addClass("dex"); $(":text").val("HelloMS"); // $("p").toggleClass("dex"); }); }); </script> </head> <body> <!--addClass() 元素添加指定的类名--> <h1>我是H1</h1> <p>我是P</p> <button>点击添加</button> <!--attr()设置或返回匹配元素的属性和值 hasClass()检查匹配的元素是否拥有指定的类 html()设置或返回匹配的元素集合中的 HTML 内容innerHTML removeAttr()从所有匹配的元素中移除指定的属性 removeClass()匹配的元素中删除全部或者指定的类--> <!-- toggleClass()匹配的元素中添加或删除--> <!--val()设置或返回匹配元素的值比如value值--> <p>姓名:<input type="text" name="Name" value="Hello Suo" /></p> <button>点击我</button> </body> </html>