jQuery click() event not firing on AJAX loaded HTML elements

前端 未结 4 1733
挽巷
挽巷 2020-12-05 00:05

the subject is pretty descriptive of my problem, I am assuming it won\'t work this way, is there a way to make it work? (workaround)?

Here is the code that is loaded

4条回答
  •  再見小時候
    2020-12-05 00:56

    you have to re-attach the event handlers to the dynamically added elements into the DOM. .live method was used widely but now its deprecated. In jQuery version 1.7+ you can use .on or alternatively you can use .delegate

    $(document).on("click",".sframe",function(e){
    
    });
    

    using delegate

    $(document).delegate(".sframe","click",function(e){
    
    });
    

提交回复
热议问题