简体   繁体   English

使用ajax调用动态添加元素后,jquery事件不起作用

[英]jquery events not working after dynamically adding elements with ajax call

its weird that all my jquery events turn unresponsive after a ajax call. 奇怪的是,我的所有jquery事件在ajax调用后都没有响应。 Im a load function call and once the jsp reloads all the events just do not respond. 我是一个加载函数调用,并且一旦jsp重新加载了所有事件,它们就不会响应。 any help ? 有什么帮助吗?

the following is the code which triggers the function call. 以下是触发函数调用的代码。

$('#personTypeId').on('change', function() {
    var selectId = document.getElementById("personTypeId").value;
    if (selectId == 1 || selectId == 4 || selectId == 8) {
        $("#directoryFilter").load("directory/filters #directoryFilter",{"selectId" : selectId  });

    }
});
$(document).on("change", "#personTypeId", function(){
    var selectId = document.getElementById("personTypeId").value;
    if (selectId == 1 || selectId == 4 || selectId == 8) {
            $("#directoryFilter").load("directory/filters #directoryFilter",{"selectId" : selectId  });
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM