我有一个HTML代码,这样如何动态创建的表元素添加事件中的iframe
<table id="Table1">
<tbody>
<tr>
<th scope="col">
Srno.
</th>
<th scope="col">
Emp code
</th>
<th scope="col">
Name
</th>
<th scope="col">
Mobile No
</th>
<th scope="col">
Delete
</th>
</tr>
</tbody>
</table>
我有一个按钮,当button
被点击的新tr
与4 td
加入到表中,代码变成这样。
<table id="Table1">
<tbody>
<tr>
<th scope="col">
Srno.
</th>
<th scope="col">
Emp code
</th>
<th scope="col">
Name
</th>
<th scope="col">
Mobile No
</th>
<th scope="col">
Delete
</th>
</tr>
<tr>
<td>
1
</td>
<td style="display: none;">
198
</td>
<td>
SHR003
</td>
<td>
Saurabh khandelwal
</td>
<td>
9891491920
</td>
<td>
<img class="clsImage" src="../../images/delete1.png" style="cursor: pointer;">
</td>
</tr>
</tbody>
</table>
现在我使用delete
图像删除其dynamically
在iframe
加入当前行。对于同样正在使用Jquery
代码:
$("iframe").contents().find('body').on("click", '.clsImage', function (e) {
alert('111');
});
但是点击之后delete
图像按钮最新加入tr
内该iframe不给alert
。
我使用`jQuery的1.9.1'
请帮我
表是iframe中?还是只有clsImage? – 2014-10-03 07:37:08
你好,表格在'iframe'里面,'clsImage'只是通过'classname'来添加元素。 – 2014-10-03 07:40:06
.live()dnt工作? – madhairsilence 2014-10-03 09:48:30