<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <div id="d1"> <p>哈哈</p> </div> <input id="input1" type="text" value="嘎嘎" /> <input id="dj" type="button" value="点击" /> <script type="text/javascript" src="../images/jquery-3.4.1.min.js"></script> <script type="text/javascript"> var dj = document.getElementById("dj"); dj.onclick = function () { / * document.getElementById ("d1"). innerHTML * / / * html parameters are used to modify the value * / / * var html = $ ("# d1"). html ( "谷 谷 谷 谷 谷 谷"); // <p> haha </ p> * / var html = $ ( " # d1 " ) .html (); // <p> haha </ p> alert ( " html: " + html); / * document.getElementById (" d1 "). innerText * / var text = $ ( "#d1").text();// haha alert ( " text: " + text); / * document.getElementById ("d1"). Value * / var val = $ ( " # d1 " ) .val (); // empty alert ( " val: " + val); / * css (properties): set a" name: value "object to all matching element style properties * / $ ( " # d1 " ) .css ({width: " 100px " , height: " 100px ",color:" red " }); / * The attribute name contains-, quotes must be used * / $ ( " # d1 " ) .css ({ " margin-top " : " 200px " }); } </script> </body> </html>