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

 

相关文章:

  • 2022-12-23
  • 2021-11-12
  • 2021-08-19
  • 2021-09-15
  • 2021-08-01
  • 2022-12-23
  • 2022-02-11
  • 2021-08-05
猜你喜欢
  • 2022-01-16
  • 2021-10-21
  • 2021-08-16
  • 2022-12-23
  • 2020-10-09
  • 2022-12-23
相关资源
相似解决方案