jQuery的转盘>悬停在转盘图像示出了在一个单独的div

问题描述:

的标记下面用于我的jQuery转盘插件全尺寸预览。第一个div用作当前选定模板缩略图的预览div。当鼠标悬停事件发生在轮播内部的任何缩略图图像上时,我希望更新预览图像以显示该图像的全尺寸缩略图(然后恢复为默认的鼠标悬停)。jQuery的转盘>悬停在转盘图像示出了在一个单独的div

转盘图像和预览图像的大小相同,我只是通过CSS设置转盘图像的大小显得更小。

//this is my full size preview image 
<div class="selectedImage"> 
    <img src="../wp-content/themes/mytheme/screenshot.jpg" /> 
</div> 
// this is the element that moves the carousel images 
<a href="#"><img class="prev" src="../wp-content/themes/mytheme/more.jpg" /></a> 

//This is the carousel. I'd like hover events to update the preview image 
// with the mouseover image, but revert back to the default onmouseout. 
<div class="carousel"> 
    <ul> 
     <li><img src="../wp-content/themes/mytheme/screenshot1.jpg" class="selected" /></li> 
     <li><img src="../wp-content/themes/mytheme/screenshot2.jpg" class="selected" /></li> 
     <li><img src="../wp-content/themes/mytheme/screenshot3.jpg" class="selected" /></li>   
    </ul> 
</div> 

btw,我使用jcarousellite_1.0.1.min.js插件为旋转木马。

+0

是什么?你试试。我的意思是你的js代码在哪里,什么不能用它 – jitter 2010-03-16 13:29:18

+0

没有代码。我希望有一个$()的快捷方式允许我用当前的onmouseover图像做些什么... – 2010-03-16 13:39:13

DEMO:http://jsbin.com/uyupu

$(function() { 
    $(".carousel").jCarouselLite({ 
     btnNext: ".next", 
     btnPrev: ".prev" 
    }); 

    $('.carousel ul li').hover(function(e) { 

    var img_src = $(this).children('img').attr('src'); 
    $('.selectedImage img').fadeOut(200).attr('src',img_src).fadeIn(200); 

} 
,function() { 

//do here what you want, or simply hide image! 
$('.selectedImage img').fadeOut(200); 
    }); 

}); 
+0

Sweeeeet!当我按原样运行它时,它完美地改变了预览图像,但是预览图像随着默认图像一起消失。我怎样才能让默认图像回来呢? – 2010-03-16 14:26:52

+0

你的意思是你有第一个预定义的图像,你想要回来,或者你只是想显示最新的图像!?前者为 – 2010-03-16 15:13:32

+0

。我已经知道了。 jQuery很漂亮。感谢您设置路径:) – 2010-03-16 17:06:50