<!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>
<title>无标题页</title>
<script type="text/javascript">
function clickA()
{
document.getElementById('a').innerHTML += "<input name=\"tbl_leaveDetail.dFromTime\" type=\"text\" />";
//alert(document.all('tbl_leaveDetail.dFromTime').length);
}
function clickB()
{
//IE8不兼容
alert(document.all('tbl_leaveDetail.dFromTime').length);
//建议使用
alert(document.getElementsByName('tbl_leaveDetail.dFromTime').length);
}
</script>
</head>
<body>
<input id="Button1" type="button" value="Add" onclick="clickA();" />
<input id="Button2" type="button" value="Compute" onclick="clickB();" />
<div id="a"></div>
</body>
</html>
document.all().length在ie8无法使用
最新推荐文章于 2013-07-19 21:56:20 发布