Search results
Use $(document).ready() instead of $(window).on("load", function... $(document).ready(function() { console.log("ready!"); }); OR its shorthand: $(function() { console.log("ready!"); }); In your case would be:
The load () method was deprecated in jQuery version 1.8 and removed in version 3.0. Use the on () or trigger () method instead. Use .on("load", handler) instead of .load(handler) and . trigger("load") instead of .load(). The load () method attaches an event handler to the load event.
The .on() method attaches event handlers to the currently selected set of elements in the jQuery object. As of jQuery 1.7, the .on() method provides all functionality required for attaching event handlers. For help in converting from older jQuery event methods, see .bind(), .delegate(), and .live(). To remove events bound with .on(), see .off().
A function to execute each time the event is triggered. This page describes the load event. For the .load() method removed in jQuery 3.0, see .load(). The load event is sent to an element when it and all sub-elements have been completely loaded.
30 sty 2023 · The onload is an event handler used to execute the required function when the onload event occurs, and the $(document).ready will occur when DOM document object model has been loaded. This tutorial demonstrates how to use onload and ready() methods in jQuery.
The onload event can be used to check the visitor's browser type and browser version, and load the proper version of the web page based on the information. The onload event can also be used to deal with cookies (see "More Examples" below).
If you want the onload method to take parameters, you can do something similar to this: window.onload = function() {. yourFunction(param1, param2); }; This binds onload to an anonymous function, that when invoked, will run your desired function, with whatever parameters you give it.