Javascript jQuery-检测添加到dom的对话框div
我正在开发一个企业应用程序。我需要对应用程序中显示的某些弹出窗口进行样式设置。我发现每当显示弹出窗口时,就会在主体中添加以下divJavascript jQuery-检测添加到dom的对话框div,javascript,jquery,dom,Javascript,Jquery,Dom,我正在开发一个企业应用程序。我需要对应用程序中显示的某些弹出窗口进行样式设置。我发现每当显示弹出窗口时,就会在主体中添加以下div <div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable ui-resizable" tabindex="-1" role="dialog" aria-describedby="ui-id-12" aria-labelledby="ui-id-13
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable ui-resizable" tabindex="-1" role="dialog" aria-describedby="ui-id-12" aria-labelledby="ui-id-13" style="position: absolute; height: auto; width: auto; top: 263px; left: 626px; display: none;">
但这是行不通的
请帮助您正在谈论dom变异事件处理。
看看这个:您可以使用DOMSubtreeModified事件。例如:
$(document).on('DOMSubtreeModified',function(){
console.log("now there are " + $('a').length + " links on this page.");
})
或
或
您可以在此处查看更多要使用的事件:并查看哪个事件更适合您。document.load如何?对不起,您能否提供document.loadI是指$(document)。on('load','div.ui-dialoog',函数(e){加载时的文档不起作用,因为用户操作后添加了对话框。我不应该使用on而不是bind吗?我使用DOMNodeInserted而不是上面提到的事件,因为它触发的次数比DOMSubtreeModified少。@Neel我还在我的评论中添加了DOMNodeInserted,只是为了使它更完整,以防有人需要它。不需要吗别忘了竖起大拇指;-)
$(document).on('DOMSubtreeModified',function(){
console.log("now there are " + $('a').length + " links on this page.");
})
$(document).on('DOMAttrModified',function(){
console.log("now there are " + $('a').length + " links on this page.");
})
$(document).on('DOMNodeInserted',function(){
console.log("now there are " + $('a').length + " links on this page.");
})