<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<script language =javascript type ="text/javascript">
function loads()
{
document .getElementById ('divs').innerHTML ='<input type=text id=htbh/>'; if(document .getElementById ('htbh'))
{
document .getElementById ('htbh').value='111111';
}
}
</script>
<body onload =loads()>
<form id="form1" runat="server">
<div id=divs>
</div>
</form>
</body>
</html>
运行后,页面上子元素htbh有值,但为什么查看源文件时DIVS则为空?
<head runat="server">
<title>无标题页</title>
</head>
<script language =javascript type ="text/javascript">
function loads()
{
document .getElementById ('divs').innerHTML ='<input type=text id=htbh/>'; if(document .getElementById ('htbh'))
{
document .getElementById ('htbh').value='111111';
}
}
</script>
<body onload =loads()>
<form id="form1" runat="server">
<div id=divs>
</div>
</form>
</body>
</html>
运行后,页面上子元素htbh有值,但为什么查看源文件时DIVS则为空?
是什么
你知道就知道了
document .getElementById ('htbh').value='111111' 不会成功的
装一个firebug你可以完全看到里面的变化情况
-------------------
源文件肯定没有,但能取到值,取不到值肯定你的JS写的有问题