预加载CSS图像 [英] Preloading CSS Images
问题描述
我有一个隐藏的联络表单,部署点击按钮。
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.
我在<$ c $中使用了这个片段,因为它的字段设置为CSS背景图片,并且它们总是显示比已经切换的div晚一些。 c>< head> 部分,但没有运气(在我清除缓存后):
I was using this snippet in the <head>
section, but with no luck (after I cleared the cache) :
<script>
$(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>
我使用jQuery作为我的库,如果我可以使用它会很酷
I'm using jQuery as my library, and it would be cool if I could use it as well for arranging this issue.
推荐答案
感谢您的支持。我可以确认我的原始代码似乎工作。我偶然坚持使用错误路径的图片。
I can confirm that my original code seems to work. I was casually sticking to an image with a wrong path.
这里是一个测试: http://paragraphe.org/slidetoggletest/test.html
<script>
pic = new Image();
pic2 = new Image();
pic3 = new Image();
pic.src="images/inputs/input1.png";
pic2.src="images/inputs/input2.png";
pic3.src="images/inputs/input3.png";
</script>
这篇关于预加载CSS图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!