双击tr取第一个td的value
tr ondblclick=dbtd(this)
Function dbtd(element){
alert(element.children[0].innerHTML)
}
输出的value值我要取到
或者大侠有其他更好的办法 蟹蟹了
element.children[0].attributes["value"].nodeValue
<html>
<head>
<script type="text/javascript">
function getInnerHTML()
{
alert(document.getElementById("tr1").innerHTML);
}
function getTDvalue()
{
//这个是用属性的方式来取值
alert(document.getElementById("tr2").children[0].attributes["value"].nodeValue);
}
</script>
</head>
<body>
<table border="1">
<tr id="tr1">
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr id="tr2">
<td id="td1" value="100" >Peter</td>
<td>Griffin</td>
</tr>
</table>
<br />
<input type="button" onclick="getInnerHTML()" value="Alert innerHTML of table row" />
<input type="button" onclick="getTDvalue()" value="Alert Value of table Td" />
</body>
</html>
这是我给你写的完整的测试例子,你保存为html文件就行,我这边用ie10和火狐测试都是可以了,没有错误
可以用原声的js,也可以用jQuery