Preloading CSS Background Images

Posted by Peanuts on Stack Overflow See other posts from Stack Overflow or by Peanuts
Published on 2009-09-03T12:34:53Z Indexed on 2011/01/06 12:53 UTC
Read the original article Hit count: 194

Filed under:
|
|
|
|

Hello guys,

I have a hidden contact form which is deployed clicking on a button. Its fields are set as CSS background images, and they always appears a bit later than the div that have been toggled.

I was using this snippet in the <head> section, but with no luck (after I cleared the cache) :

<script type="text/javascript">
$(document).ready(function() {
    	pic = new Image();
    	pic2 = new Image();
    	pic3 = new Image();
    	pic.src="<?php bloginfo('template_directory'); ?>/images/inputs/input1.png";
    	pic2.src="<?php bloginfo('template_directory'); ?>/images/inputs/input2.png";
    	pic3.src="<?php bloginfo('template_directory'); ?>/images/inputs/input3.png";
});
</script>

I'm using jQuery as my library, and it would be cool if I could use it as well for arranging this issue.

Thanks for your thoughs.

© Stack Overflow or respective owner

Related posts about css

Related posts about image