jquery图像滑块库
jquery image slider gallery
我正在尝试在预览元素中动态添加图像。所以当我点击缩略图时,图像会加载并滑动。
<div id="imageGallery">
<div id="loading"></div>
<a class="thumbnail"><img alt="Image 1" src="../../baContent/image1.jpg" /></a>
<a class="thumbnail"><img alt="Image 2" src="../../baContent/image2.jpg" /></a>
<div id="preview">
<img id="mainImage" alt="Main Image" src="../../baContent/image1.jpg" />
</div>
</div>
$(document).ready(function () {
$("#loading").show();
var oldImage = $("#preview img:first");
var newImage = $("#mainImage").insertAfter(oldImage).css('position', 'absolute').css('left', 800);
newImage.load(function () {
$("#loading").hide();
oldImage.css({ left: 0 }).animate({ left: -800 });
newImage.css({ left: 800 }).animate({ left: 0 });
oldImage.remove();
});
});
我的想法是在第一个图像和旧图像删除后动态插入图像。我尝试了许多函数append、insertTo。但它不起作用。感谢建议:)
我想你想得太复杂了。。。
$(document).ready(function(){
$(".thumbnail").click(function(){
$("#loading").show();
// Create new image instance
$("<img/>", {
// Get source of image to load
src: $(this).find("img").attr("src")
}).css({
position: "absolute",
left: 800
}).load(function(){
$("#loading").hide();
// Append new image to preview div
$("#preview").append($(this));
// Get current image and animate it
$("#preview").find("img:first").css({
position: "absolute"
}).animate({
left: -800
}, function(){
// Remove the image when animation complete
$(this).remove();
});
// Animate new image
$(this).animate({
left: 0
}, function(){
// Do something interesting...
});
});
});
});
在此处进行测试:http://jsfiddle.net/dpzdL/
相关文章:
- 使用带括号的图像URL作为jQuery的背景
- 如何使用jquery将base64图像路径转换为真实路径
- 重新加载/替换图像 jQuery 作为
- 中的列表项
- 鼠标悬停在图像 jquery 上
- 使用图像 jQuery 切换
- 检查显示的(随机)图像是否与上一个(随机)图像(jQuery和JavaScript)相同
- 更改背景图像 jQuery
- 单击函数不在图像jQuery上启动
- 预览图像Jquery脚本don't运行良好
- 使用图像Jquery对话框预加载iFrame
- jQuery脉动代码与滚动图像jQuery代码冲突
- 检测粘贴事件在浏览器中的图像(jquery/javascript)
- 图像库与覆盖和html内部不能覆盖正确的图像.jquery
- 预加载图像- JQuery
- 使用HTML扩展图像&Jquery
- 从Rest API获取图像.JQuery的问题
- 使用尽可能多的独立线程检索5个图像- jquery ajax
- 点击图像jQuery -函数不工作后追加
- 如何使用XML数据更改网站上的图像&jQuery
- 在不向服务器发出新请求的情况下更改图像jQuery