预加载图像并在加载时显示微调器

编程入门 行业动态 更新时间:2024-10-04 21:20:48
本文介绍了预加载图像并在加载时显示微调器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Hy,

我使用uploadify上传一些图片,在我显示列表中的所有图像后,当我点击图像拇指时,它是一个更大的图像使用此功能在div中打开

i use uploadify to upload some images, after i display all the images thumbs in a list, when i click on a image thumb a bigger image it's open in a div with this function

$(".thumbs li a").click(function(){ var largePath = $(this).attr("href"); $('.thumbs li').removeClass('thumbac'); $(this).parent().addClass('thumbac'); $("#largeImg").attr({ src: largePath }); return false; });

这是我的照片列表:

<div class="upimage"> <ul id="upimagesQueue" class="thumbs"> <li id="liupimages"> <a href="uploads/0001.jpg"><img src="uploads/0001.jpg" alt="0001.jpg" id=""></a> </li> <li id="liupimages"> <a href="uploads/0002.jpg"><img src="uploads/0002.jpg" alt="0002.jpg" id=""></a> </li> <li id="liupimages"> <a href="uploads/0003.jpg"><img src="uploads/0003.jpg" alt="0003.jpg" id=""></a> </li> <script> $(".thumbs li a").click(function(){ var largePath = $(this).attr("href"); $('.thumbs li').removeClass('thumbac'); $(this).parent().addClass('thumbac'); $("#largeImg").attr({ src: largePath }); return false; }); </script> </ul> </div>

这是图像出现的div

this is the div where the images appear

<div class="largeImg" > <img id="largeImg" src="" /> </div>

如何在显示之前预先加载图像?

how i can preload the image before it display?

推荐答案

您可以通过某种方式利用 加载 事件,例如:

You can somehow harness the load event, e.g.:

$(".thumbs li a").click(function(){ var largePath = $(this).attr("href"); $('.thumbs li').removeClass('thumbac'); $(this).parent().addClass('thumbac'); $("#largeImg").hide() .attr({ src: largePath }) .load(function() { $(this).show(); }); return false; });

更多推荐

预加载图像并在加载时显示微调器

本文发布于:2023-11-03 04:41:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554260.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   并在   图像

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!