87,910
社区成员
发帖
与我相关
我的任务
分享
<!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=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function add(){
var oInput=document.createElement("input");
oInput.setAttribute("type","text");
oInput.setAttribute("value","1234567");
oInput.setAttribute("id","bbb1");
oInput.setAttribute("name","bbb");
var aaa=document.getElementById("aaa");
aaa.appendChild(oInput);
}
function get(){
var ccc=document.getElementsByName("bbb");
//var ccc=document.getElementById("bbb1");
alert(ccc[0].value);
}
</script>
</head>
<body>
<input type="button" onclick="get();" value="name取得值" /><br />
<input type="text" value="dddddddd333" name="ttt"/><br/>
<input type="button" onclick="add();" value="增加" /><br />
<div id="aaa">
</div>
</body>
</html>
<!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=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function add(){
var oInput=document.createElement("input");
oInput.setAttribute("type","text");
oInput.setAttribute("value","1234567");
oInput.id="bbb1";
oInput.name="bbb";
var aaa=document.getElementById("aaa");
aaa.appendChild(oInput);
}
function get(){
var obj=document.getElementsByTagName("input")
for (var i=0;i<obj.length;i++)
if (obj[i].name=="bbb")
alert(obj[i].value)
}
</script>
</head>
<body>
<input type="button" onclick="get();" value="name取得值" /><br />
<input type="text" value="dddddddd333" name="ttt"/><br/>
<input type="button" onclick="add();" value="增加" /><br />
<div id="aaa">
</div>
</body>
</html>
newInput = document.createElement("<INPUT TYPE='text' NAME='test' VALUE='123'>")
function get(){
/*var ccc=document.getElementsByName("bbb");
//var ccc=document.getElementById("bbb1");
alert(ccc[0].value);*/
alert(document.getElementById("aaa").innerHTML)
}
<script type="text/javascript">
function add(){
document.getElementById("aaa").innerHTML = "<input type='text' name='bbb' value='123456' />";
}
function get(){
alert(document.getElementsByName("bbb")[0].value);
}
</script>