我想要类似的东西:
$('.pac-container').whenAddToDom(function(){
console.log('element with class pac-container added to DOM');
//I want to use this added element $(this).doSomethingWithThis();
});
答案 0 :(得分:2)
我会将要附加在容器中的元素包装起来并执行以下操作:
$("html").bind("DOMNodeInserted",function(){
console.log('element with class '+$("#container > *").attr('class') +' added to DOM');
});
答案 1 :(得分:0)
这是我的问题的解决方案:
$(document).bind('DOMNodeInserted DOMNodeRemoved', function(element){
if($(this).hasClass('pac-container')){
console.log(element.target);
}
});