标签:
代码;
<html> <head> <title>js标签属性的添加</title> <script > function setxxx(){ alert("xx"); var box = document.getElementById("box"); var oLi = document.createElement("li"); var oH3 = document.createElement("h3"); oH3.innerHTML = "这是js生成的一个h3的标签"; oH3.style.height="30px"; oH3.style.background = "red"; oH3.setAttribute(‘class‘,‘dtime‘); box.appendChild(oH3); } </script> </head> <div id="box"> <input type="button" value="点击" onclick="setxxx()" /> </div> <body> </body> </html>
截图:
标签:
原文地址:http://www.cnblogs.com/sunxun/p/5222114.html