// 绑定onchange事件 ---新增的元素事件不生效
//$(".fixedInput").bind("input propertychange change",function(event){
// var _divs = $(".fixedInput").parent().parent().find("select");
// var select = _divs.eq(0).find("option:selected");
// select.val("fixedValue" + $(this).val());
// form.render();
//});
// 使用此方式-新增的元素事件生效
$(document).on("change",".fixedInput",function(){
console.log(234324);
var _divs = $(".fixedInput").parent().parent().find("select");
var select = _divs.eq(0).find("option:selected");
select.val("fixedValue" + $(this).val());
form.render();
})
Layui 新增的元素事件不生效
最新推荐文章于 2023-07-28 10:30:08 发布
本文探讨了在新增元素上使用jQuery的on方法进行事件绑定的有效策略,对比了bind方法的局限性,展示了如何确保动态生成的元素也能响应事件。
2万+

被折叠的 条评论
为什么被折叠?



