动态插入的html代码,点击节点无效以及获取节点下标的方法

动态插入的html,需要使用delegate或者on事件来监听,方式如下。 如果需要获取节点对应的下标,$(this).index()是无法获取的,需要以$(selectot).index(this)方式来获取

$('body').on('click', '.delete-pic', function () {
console.log($('.delete-pic').index(this))
})

猜你喜欢

转载自www.cnblogs.com/cazj/p/11016492.html