Jquery gets the height or width of the image after the page loads
- 2020-03-30 03:23:13
- OfStack
Recently, this technology has encountered an interesting problem. According to the project's requirements, it is necessary to obtain the height of the image after the page is loaded, so as to adjust the position of the overlay above the image relative to the top of the image.
But in the jquery (function () {}); I found it was not very good, because when jquery was ready, most of the images were not loaded, which was bad
Ben zhusi thought, if only jquery had a method like js onload (), how nice it would be!
When Ben zhusi saw this method, it was like seeing a piece of shining dog poop in the slum. She tried it. Wow! It worked!
I have to admire the power of jquery! For the insurance period, deep evolution has been carried out, the code is as follows:
But in the jquery (function () {}); I found it was not very good, because when jquery was ready, most of the images were not loaded, which was bad
Ben zhusi thought, if only jquery had a method like js onload (), how nice it would be!
$(window).load(function() {
alert(" Guess the picture is loaded? ");
});
When Ben zhusi saw this method, it was like seeing a piece of shining dog poop in the slum. She tried it. Wow! It worked!
I have to admire the power of jquery! For the insurance period, deep evolution has been carried out, the code is as follows:
jQuery(function(){
jQuery(window).load(function(){
});
});