日期:2014-05-17 浏览次数:20843 次
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
//创建 input 文本框
var test=1
function CreateInput(){
var obj = document.getElementById("body_note");
nDiv = document.createElement("div");
nDiv.id="showText"+test;
obj.appendChild(nDiv);
var input = document.createElement("input");
input.type = "text";
input.id = "inputText";
input.value = test;
var input2 = document.createElement("input");
input2.type = "button";
input2.id = "button"+test;
input3=input2.id
input2.value = "button"+test;
input2.onclick = function(){testa(this);};
document.getElementById("showText"+test).appendChild(input);
document.getElementById("showText"+test).appendChild(input2);
test++;
}
function testa(t){
alert (t.value)
}
</script>
</head>
<body id="body_note" onload="CreateInput()">
<input type="button" name="test" id="test" value="add" onclick="CreateInput()" />
</body>
input2.onclick = function(){testa(this);};
input2.onclick = "testa(this)";