Dave's Brain

Browse - Programming Tips - How do I preload an image using jQuery?

Date: 2012jul4
Language: javaScript
Platform: web

Q.  How do I preload an image using jQuery?

A.  Create and use an Image object in your ready() function:

$(document).ready(function() { var myimg = new Image; myimg.src = 'images/myimg.jpg'; });

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.