You can use
$(window).on('load', function() {
// your code here
});
Which will wait until the page is loaded. $(document).ready()
waits until the DOM is loaded.
In plain JS:
window.addEventListener('load', function() {
// your code here
})
More Related Contents:
- How can I make my header smaller if i will scroll down the webpage [closed]
- Height equal to dynamic width (CSS fluid layout) [duplicate]
- JavaScript asynchronous return value / assignment with jQuery [duplicate]
- Long Press in JavaScript?
- Set timeout for ajax (jQuery)
- jQuery scroll() detect when user stops scrolling
- Ajax request returns 200 OK, but an error event is fired instead of success
- Where do you include the jQuery library from? Google JSAPI? CDN?
- Access-Control-Allow-Origin denied spotify api [duplicate]
- jQuery DOM changes not appearing in view source
- Prototyping Object in Javascript breaks jQuery?
- jQuery Text to Link Script? [duplicate]
- Saving a text file on server using JavaScript
- Changing width property of a :before css selector using JQuery [duplicate]
- Dashed border animation in css3 animation
- Callback function after tooltip / popover is created with twitter bootstrap?
- jQuery – Redirect with post data
- Using mousedown event on mobile without jQuery mobile?
- Click on option event
- Disable zooming of the page in desktop web browsers using Javascript/Jquery [duplicate]
- Fade background image in and out with jQuery?
- blur vs focusout — any real differences? [duplicate]
- How to convert a Title to a URL slug in jQuery?
- How to do something before on submit?
- how to convert xml to json using jquery
- JQuery issue “TypeError: $.getJSON is not a function”
- Best JavaScript Date Parser & Formatter? [closed]
- how to use jQuery installed with npm in Express app?
- Parse ‘Date & Time’ string in Javascript which are of custom format
- Masking a social security number input