after ajax call jquery function not working properly

前端 未结 3 747
南方客
南方客 2021-01-15 17:02

headers :




        
相关标签:
3条回答
  • 2021-01-15 17:03

    Because you bounded the functionality of the click event even before the new content is injected to the DOM. So that functionality will not be available to the newly added (injected) dynamic content. To handle this , you need to use jQuery on

    So Change your code from

    $(function(){
       $(".cmdclose").click(function(){    
         // your code    
       });
    });
    

    to

    $(function(){
        $(document).on("click",".cmdclose",function(){
           //your code
        });
    });
    

    jQuery on will work for current and future elements. on is avaialbe from jQuery 1.7+ onwards. If you are using a previous version of jQuery, use live

    0 讨论(0)
  • 2021-01-15 17:11

    try:

    $(".cmdclose").live("click",function(){...
    
    0 讨论(0)
  • 2021-01-15 17:11

    problem in your jquery code your code like this.

    $(".cmdclose").click(function()
    

    problem is "cmdclose" this class is not available in your html par.

    so first you need to specify the this class in html tag like div,tr etc.

    after that its working plz try this

    0 讨论(0)
提交回复
热议问题