首页 > Web开发 > 详细

JavaScript CreateElement Div

时间:2014-03-12 10:00:58      阅读:463      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
<title> CreateElement </title>

    
<script type="text/javascript">
    
function CreateElement()
    {
        
var newE = document.createElement("DIV");
        
        newE.id 
= "div2";
        newE.innerHTML 
= "this is a test div " + new Date() + "<br/>";
        newE.style.borderStyle 
= "solid";
        newE.style.borderColor 
= "Red";
        newE.style.borderWidth 
= "1px";

        
//document.getElementById("div1").appendChild(newE);
        document.getElementById("div1").insertBefore(newE,null);
        
//document.body.appendChild(newE);
    }
    
</script>

</head>
<body>

    
<input id="Button1" type="button" value="CreateElement" onclick="CreateElement();" />
    
<input id="Button2" type="button" value="Get" onclick="GetElement();" /><br /><br />
    
    
<div id="div1" style="border-style: solid; border-color: Green; border-width: 1px; padding:5px;"> this is a div </div>

</body>
</html>

 

文章转自:http://www.cnblogs.com/abeen/articles/1433405.html

JavaScript CreateElement Div,布布扣,bubuko.com

JavaScript CreateElement Div

原文:http://www.cnblogs.com/loushuibazi/p/3595509.html

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