Home > Web Front-end > JS Tutorial > body text

jquery implements getting the image height or width after the page is loaded_jquery

WBOY
Release: 2016-05-16 16:44:13
Original
1536 people have browsed it

Recently, this technical person encountered another very interesting problem. In response to project requirements, it was necessary to obtain the height of the image after the page was loaded, so as to adjust the position of the overlay on the image relative to the top of the image.

But after writing it in jquery(function(){ /*XXXXXX*/});, I found that it is not very ideal, because when jquery is ready, the image is not loaded in most cases. Finished, this is really annoying~~~T~T

I just thought, if only jquery had a method like js’s onload(), it would be great. Oh~ It’s really falling from the sky. Big shit happened to hit this loser~~ After searching on the Internet, there is such a method. It is written as follows:

Copy code The code is as follows:

$(window).load(function() {
alert("Have you guessed the image has been loaded?");
});

When this loser saw this method, it was like seeing a piece of golden shit in the slums~~ So she quickly tried it, wow~~~wow~~~wow~~~it’s so cool ! It’s really solved!

I have to admire the power of jquery! For the insurance period, a deep evolution has been carried out, the code is as follows:
Copy the code The code is as follows:

jQuery(function(){
jQuery(window).load(function(){
/*Operations on images, you can get img height, width, perform some series of operations, etc.!*/
} );
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template