今天晚上学习了,Javascript中的showdiv具体例子代码跟大家分享一下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function showDiv(){
var new_div=document.createElement('div');
new_div.style.width='200px';
new_div.style.height='200px';
new_div.style.backgroundColor='blue';
new_div.id='div1';
document.body.appendChild(new_div);
var text=document.createTextNode('中华人民共和国万岁丶');
new_div.appendChild(text);
alert(document.getElementById('div1').nodeName);
}
</script>
<input type="button" οnclick="showDiv()" value="O(∩_∩)O~">
</head>
<body bgcolor="#66FFFF">
</body>
</html>