简体   繁体   中英

How to remove class which are created dynamically using jQuery

$("#my").click(function() {
    $(this.title).remove();
});

I have work with jQuery dynamically add and remove html content,but how to remove which create dynamically added.

use on event delegation for dynamically added element

try this

 $(document).on("click","#my",function(){
    $(this).removeClass(this.title);
     //or
     $(this.title).remove();
  });

i suppose

$('#my').click(function(){
   $(this).removeClass(this.title);
   $(this).addClass(this.title);  
   $(this).toggleClass(this.title);
})

You are looking for one of these?

just try it

$("#my").live('click',function()
{
 $(this.title).remove();
}
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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