Moh*_*uli 0 jquery html-table mouseenter
我创建了以下代码:
<table id="map">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
<script>
$(document).ready(function(){
$('td:last-child').mouseenter(function(){
var tdId = $(this).attr('id');
var newId = parseInt(tdId);
$(this).after('<td>new</td>');
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
td当鼠标在最后一个孩子上输入tds时,我想创建一个新的.该代码正在运行.但是当我想再次创建一个新的td时,我必须将其悬停在自动创建的<td>3</td>最后一个上面td!我怎么解决这个问题?!
使用事件委派而不是将处理程序直接绑定到td元素:
$('#map').on('mouseenter', 'td:last-child', function(){
// code here
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1478 次 |
| 最近记录: |