1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div class="one">111</div> <p>pppp</p> <input type="text" value="默认值"/> <a href="###" id="a1">超链接</a> <div id="box"> <span>span行元素</span> </div> </body> </html> <script type="text/javascript"> var one = document.getElementsByClassName("one")[0]; one.style.backgroundColor = "pink"; one.style.height = "100px";
document.write("哈哈哈你好!!"); document.write("0000789789!!"); document.write("<h1>大标题</h1>");
one.innerHTML = "周润发"; console.log(one.innerHTML); one.innerHTML = one.innerHTML + "周星驰"; one.innerHTML += "<p>直接写入标签</p>";
var p = document.getElementsByTagName("p")[1]; p.innerText = "哈哈"; p.innerText += "<a href='###'>京东</a>" var i1 = document.getElementsByTagName("input")[0]; i1.value = "哈哈哈哈我试试!"; i1.value += "肯定可以拼接!"; console.log(i1.value); </script>
|