event.target
函数对于div元素效果良好,但对于表格元素则不行。HTML代码:
<div class="one body" >
sd
</div>
<div class="two body">
sddsd
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="three body">jjj</table>
JS:
$(".body").click(function(e){
alert("xxxxxxxxx"+e.target.className);
});
jjj
其实并没有在表格中渲染出来。你需要(先加上<tbody>
,然后)添加一个<tr>
,最后是<td>
。 - gen_Eric