开发者

Call a javascript function after loading the Div

开发者 https://www.devze.com 2022-12-25 04:39 出处:网络
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 eve

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

精彩评论

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