开发者

Call a javascript function after loading the Div

How to call the javascript function, after loading the par开发者_如何学Goticular div?


Typically, JavaScript execution is deferred till after the entire document is loaded by using the window.onload event.

window.onload = function() {
    // Do stuff
};

Otherwise, if you don't want to or if you have no need to wait for the entire document to load, you can include your JavaScript directly after the closing tag of the element (div) which you are concerned with.

<div>
  ...
</div>
<script src="blah-blah-blah.js"></script>


I'd check if div exists in DOM like this : javascript

 if(document.getElementById('myDiv'))

or jQuery

if($("#myDiv"))

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜