jquery live event for added dom elements

后端 未结 3 1647
春和景丽
春和景丽 2020-11-30 14:00

I want to add a class to any DOM element that is on the page now or in the future that has a specified class and meets some criteria

so for some pseudo code

3条回答
  •  情书的邮戳
    2020-11-30 14:09

    jQuery's live() feature is just subset of the livequery plugin, which is much richer. If you use livequery you could do something like..

    $('.location').livequery(function() {
       // perform selector on $(this) to apply class   
    });
    

    That will cover existing elements plus any future elements added to the DOM.

提交回复
热议问题