Reputation: 6753
I have a canvas element in my page. I need that to finish loading before calling javascript file .any suggestions
Upvotes: 0
Views: 308
Reputation: 7316
The old and best way is to place JS code towards the end of the page, just inside the closing body tag. Thus you can assure that the DOM is ready.
Upvotes: 1
Reputation: 324750
Put the <script>
tag somewhere after the <canvas>
tag.
Or use jQuery (ugh) and its document ready
thing, whatever...
Upvotes: 2
Reputation: 221
You can use jQuery and put your code inside a function
$(document).ready(function () {
// put code here
});
Upvotes: 2