If you know what elements to expect, you can use setInterval
to poll the DOM to see when they've been inserted. For example, this is how you could poll for an element with ID foo
:
$(window).load(function ()
{
var i = setInterval(function ()
{
if ($('#foo').length)
{
clearInterval(i);
// safe to execute your code here
}
}, 100);
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…