What is an alternative to loading windows?

I have the following situation: I want to show my images right away only when the page is fully loaded, because I want to avoid displaying the images one by one inside the documentโ€™s readiness function (they are initially hidden and want to show them right away only when the document is loading), therefore I am using $(window).load(function () {});

When I use this function, it works fine and behaves as expected, but my only problem is that the download function is outdated .

For example, if I use the code below without $(window).load , I can see that my images are loaded one by one, which is not an option (setTimeout is also not a parameter).

My question is: how can I achieve the same behavior without using $(window).load ? Thanks!

Code example:

 $(document).ready(function(){ //on document ready HIDE my images glowHide.hide(); //on page LOAD show all images AT ONCE (works fine but depreciated) $(window).load(function(){ glowHide.show(); }); }); 
+2
source share
1 answer

To associate the load event with a window, you must use the on method provided by jQuery.

The .on () method attaches event handlers to the currently selected set of elements in the jQuery object. Starting with jQuery 1.7, the .on () method provides all the functions needed to attach event handlers.

 $(window).on("load", function(){...}) 
+8
source

Source: https://habr.com/ru/post/1482572/


All Articles