Js 的 getAtrribute 取不到 TR TD 的属性
JS只能取出Table节点的属性, 而不能取出 TR 或TD 节点的属性 , 很奇怪.为何?
<html>
<head>
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function window_onload()
{
alert( document.getElementById("a").getAttribute("datafld") ) ;
alert( document.getElementById("b").getAttribute("datafld") ) ;
alert( document.getElementById("c").getAttribute("datafld") ) ;
}
</script>
</head>
<body onload="return window_onload()">
<form id="form1">
<div id="a" datafld="aeff">
<table id="msgTable" style="width: 100%">
<tr id="b" datafld="aeff">
<td id="c" title="优先级" datafld="aeff">
ff
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<head>
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function window_onload()
{
alert( document.getElementById("a").getAttribute("datafld") ) ;
alert( document.getElementById("b").getAttribute("datafld") ) ;
alert( document.getElementById("c").getAttribute("datafld") ) ;
}
</script>
</head>
<body onload="return window_onload()">
<form id="form1">
<div id="a" datafld="aeff">
<table id="msgTable" style="width: 100%">
<tr id="b" datafld="aeff">
<td id="c" title="优先级" datafld="aeff">
ff
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
作者:NewSea 出处:http://newsea.cnblogs.com/
QQ,MSN:iamnewsea@hotmail.com 如无特别标记说明,均为NewSea原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。 |