Alex Alex - 1 year ago 56
jQuery Question

How to do jquery code AFTER page loading?

If you want an event to work on your
page, you should call it inside the
$(document).ready() function.
Everything inside it will load as soon
as the DOM is loaded and before
the page contents are loaded.

I want to do javascript code only after the page contents are loaded how can I do that?

Answer Source

Use load instead of ready:

$(document).load(function () {
 // code here

Update - you need to use $(window).on('load', function() {... since jQuery 1.8.

From this answer:

According to

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.