开发者社区> 问答> 正文

jquery hover移到动态添加的区域,显示异常

$("#post-buy-table").find("tr:gt(0)").hover(function(){
    var $itemEditIcon = $("<td class='item-edit-icon'><span class='glyphicon glyphicon-edit'></span><span class='glyphicon glyphicon-trash'></span></td>");
    $(this).find("td:nth-child(3)").replaceWith($itemEditIcon);
},function () {
    $(this).find("td:nth-child(3)").replaceWith("<td></td>");
});

展开
收起
小旋风柴进 2016-05-31 10:26:05 1686 0
1 条回答
写回答
取消 提交回答
  • 动态添加的元素用on去绑定事件
    `
    $("#post-buy-table").on("hover","tr",function(){
    })`

    2019-07-17 19:21:27
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载