dynamically added class can't be called

后端 未结 3 635
醉梦人生
醉梦人生 2020-12-19 14:15

I am trying to accomplish delete in page which is filled with data by ajax call. my page has this before data is loaded:



        
相关标签:
3条回答
  • 2020-12-19 14:59

    Use something like this to call dynamically added class

    $('.class').live("click", function(){
    
      $('#id').remove();   
    
    
    });
    
    0 讨论(0)
  • 2020-12-19 15:06

    Try $(e.target).remove(),

    $("#ShowSelectedCategories").click(function(e){
             $(e.target).remove();    
             e.preventDefault();
    });
    

    If you want to delete element with class DeleteCat within span with id ShowSelectedCategories then you can do it like this,

    $("#ShowSelectedCategories").on("click", "DeleteCat" function(e){
             $(this).remove();    
             e.preventDefault();
    });
    
    0 讨论(0)
  • 2020-12-19 15:07
    $('#ShowSelectedCategories').on('click', '.DeleteCat', function(e){
        $(this).remove();
        e.preventDefault();
    });
    

    http://jsfiddle.net/Dj5NQ/

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