In response to project requirements, you need to obtain the Image Height after the page is loaded. In this example, jquery is used to complete this function. For more information, see the following day, this technology also encountered an interesting problem. In response to the project requirements, the height of the image needs to be obtained after the page is loaded, to adjust the position of the overlay layer on the image relative to the top of the image.
But after writing in jquery (function () {/* XXXXXX */}); It is not ideal, because when jquery is ready, at this time, the image has not been loaded in most cases, which can lead to sharp damage ~~~ T ~ T
I just thought about it. It would be nice if jquery had an onload () method with js ~ It's really a big shit in the sky. It happened to hit Ben diaosi ~~ I searched the internet and found this method. The method is as follows:
The Code is as follows:
$ (Window). load (function (){
Alert ("do you guess the image has been loaded? ");
});
Ben diaosi saw this method, as if he saw a piece of golden shit in the slums ~~ Hurry up and try again ~~~ Wow ~~~ Wow ~~~ Great! Actually solved it!
I have to admire the strength of jquery! The Code is as follows:
The Code is as follows:
JQuery (function (){
JQuery (window). load (function (){
/* Perform operations on the image to obtain the img height, width, and some column operations! */
});
});