abstrakt:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box{ width:100px; height:100p
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .box{ width:100px; height:100px; border:1px solid black; } .box1{background-color:red;} .aa{color:red;font-size:30px;} </style> <script type="text/javascript" src="jquery-3.3.1.js"> </script> </head> <body> <div></div> <input type="text" name="user"> <input type="" value="hello,world"> <p>hello world!~~~</p> <button id="bt">啪啪</button> <button id="bt1">不hello點(diǎn)我</button> <br> <i>傾斜</i> <input type="button" value="變成標(biāo)題點(diǎn)我" id="bt3"> <br> <input type="button" value="還想變標(biāo)題?" id="bt4"> <script type="text/javascript"> $(document).ready(function(){ $('div').addClass('box box1') $('div').removeClass('box1') $('.text').attr('type','password') // $('input').removeAttr('value') alert($('input').hasClass('text')) $('#bt').click(function(){ $('p').toggleClass('aa') }) $('#bt1').click(function(){ $('p').text('哈嘍,世界') }) $('#bt3').click(function(){ $('i').html('<h1>我已經(jīng)變成了標(biāo)題</h1>') }) $('#bt4').click(function(){ $('#bt3').val('我還是能變成標(biāo)題') }) }) </script> </body> </html>
以我現(xiàn)在的知識面,感覺屬性的操作好像有點(diǎn)多此一舉??赡苁沁€未深入學(xué)習(xí),所以還不能體會這些功能的妙處