jqappend()新增的dom如何控制新增的dom无法使用jquery如何解决javascript$("#addVolumePrice").click(function(){$("#thisVolumePrice").append(' [-]'+'优惠数量'+'优惠价格');});$(".redVolumePrice").live("click",function(){alert('111');});$(".redVolumePrice").on("click",function(){alert('111');});
2 回答

繁花不似锦
TA贡献1851条经验 获得超4个赞
$(".redVolumePrice").live("click",function(){alert('111');});$(".redVolumePrice").on("click",function(){alert('111');});这样当然不行的,$("outerSelector").on('eventType','selector',function(){});outerSelector是一个一直存在的DOM,selector是你要监听点击的节点;所以正确的写法是$("#thisVolumePrice").on("click",'.redVolumePrice',function(){alert('111');});具体原理可以搜索javascript事件代理//多谢@nightire的提醒

慕斯709654
TA贡献1840条经验 获得超5个赞
这么写试试吧:javascript$('#thisVolumePrice').on('click','.redVolumePrice',function(evt){console.log(evt);//去看看console里打印的evt对象,里面有一些东西很有用。});
添加回答
举报
0/150
提交
取消