<script>
function showDetail(event) {
event=event||window.event;
var target=event.target||event.srcElement;
alert(target.tagName);
if ( String(target.tagName).toLowerCase()=='input' && target.value=="详细信息") {
alert(target.getAttribute('userid') );
}
}
</script>
<html>
<body>
<table width="300" border="1" onclick="showDetail(event)">
<tr>
<td>1</td>
<td>Tom</td>
<td><input type="button" value="详细信息" userid="1" /></td>
</tr>
<tr>
<td>2</td>
<td>Kate</td>
<td><input type="button" value="详细信息" userid="2" /></td>
</tr>
<tr>
<td>3</td>
<td>John</td>
<td><input type="button" value="详细信息" userid="3" /></td>
</tr>
</table>
<table width="300" border="1" onclick="showDetail(event)">
<tr>
<td>1</td>
<td>Tom</td>
<td><input type="button" value="详细信息" userid="1" /></td>
</tr>
<tr>
<td>2</td>
<td>Kate</td>
<td><input type="button" value="详细信息" userid="2" /></td>
</tr>
<tr>
<td>3</td>
<td>John</td>
<td><input type="button" value="详细信息" userid="3" /></td>
</tr>
</table>
</body>
</html>
event使用
最新推荐文章于 2022-08-05 10:29:45 发布