首页 > Web开发 > 详细

JS手动创建标签

时间:2016-02-27 00:44:35      阅读:273      评论:0      收藏:0      [点我收藏+]

代码;

<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>

截图:

技术分享

JS手动创建标签

原文:http://www.cnblogs.com/sunxun/p/5222114.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!