load event
<script type="text/javascript"> $('img').onload = function() { //code }</script>Advantages: Simple and easy to use, without affecting HTML code.
Disadvantages: Only one element can be specified, and the javascipt code must be placed below the image element
jquery method
<script type="text/javascript">$(function(){ $('.pic1').each(function() { $(this).load(function(){ $(this).fadeIn(); }); }); })</script>Note that do not bind the load event in $(document).ready().
Advantages: Element events can be bound in batches and does not affect HTML code content
Disadvantages: The support of the jquery library is required, and the code needs to be placed below the element that needs to be operated.
The above method to determine whether the image is loaded is recommended by javascript. This is all the content shared by the editor. I hope it can give you a reference and I hope you can support Wulin.com more.