2

How to call the javascript function, after loading the particular div?

1
  • "loading particular div"? Sounds like you're using some JavaScript library and knowing which one would really help to find right answer. Commented Apr 2, 2010 at 6:41

2 Answers 2

3

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>
Sign up to request clarification or add additional context in comments.

Comments

1

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

 if(document.getElementById('myDiv'))

or jQuery

if($("#myDiv"))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.