鼠标放到小图,然后显示大图 http://www.360buy.com/product/160592.html这个里面的, 鼠标放到多个小图上面 ,上面换成大图的 这样的js有吗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.cnblogs.com/cloudgamer/archive/2008/07/06/1236770.html可以参考这个 设置它的宽 和高 一个隐藏的img this.parentNode.src="" 人家网站把那个javascript都写得很明显了。你试试查看源文件$("#mycarousel li").mouseover(function(){ $("#Product_BigImage img")[0].src="http://img10.360buyimg.com/S1/"+this.getElementsByTagName("img")[0].name; $("#Product_BigImage img")[0].jqimg="http://img10.360buyimg.com/S0/"+this.getElementsByTagName("img")[0].name; $(this).siblings().each(function(){ this.getElementsByTagName("img")[0].className=""; }) this.getElementsByTagName("img")[0].className="curr"; })};主要是用到jQuery的mouseover和each两个函数。前者就不用说了。后者主要是再document ready时给一组COM控件添加mouseover事件。可以完全把图片都定义在css里面。这里只是再mouseover时给上面那个大图显示区换css就OK了。 我不是script高手,就是希望能帮到你。呵呵 有啊 在diaplay的两个属性设置图片的大小 none隐藏;block显示 <TABLE> <TR> <TD><img id="bigpic" src="http://img10.360buyimg.com/S1/4633/67599a06-edbc-4a07-87a2-8a6db67eb7b3.jpg" border="1"></TD> </TR> <TR> <TD> <img src="http://img10.360buyimg.com/S5/4633/67599a06-edbc-4a07-87a2-8a6db67eb7b3.jpg" border="0" onmouseover="big(this)"> <img src="http://img10.360buyimg.com/S5/3474/8d7b3df9-c57c-424e-8805-004b2c2bb819.jpg" border="0" onmouseover="big(this)"> <img src="http://img10.360buyimg.com/S5/2585/aef504c7-31af-41af-90ba-7c48e4e17682.jpg" border="0" onmouseover="big(this)"> <img src="http://img10.360buyimg.com/S5/443/8fd17e13-a911-4b64-97f1-e49395a028ab.jpg" border="0" onmouseover="big(this)"> <img src="http://img10.360buyimg.com/S5/2918/61e6ef8f-22fc-4d1d-ae6c-d173cb0ff3d5.jpg" border="0" onmouseover="big(this)"> </TD> </TR> </TABLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function big(obj){ bigpic.src = obj.src.replace("S5","S1"); } //--> </SCRIPT> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>放大镜效果</title><link href="css/jqzoom.css" rel="stylesheet" type="text/css" media="screen" /><script type="text/javascript" src="js/jquery.js"></script><script type="text/javascript">(function($){$.fn.jqueryzoom=function(options){var settings={xzoom:200,yzoom:200,offset:10,position:"right",lens:1,preload:1};if(options){$.extend(settings,options)}var noalt='';$(this).hover(function(){var imageLeft=$(this).offset().left;var imageTop=$(this).offset().top;var imageWidth=$(this).children('img').get(0).offsetWidth;var imageHeight=$(this).children('img').get(0).offsetHeight;noalt=$(this).children("img").attr("alt");var bigimage=$(this).children("img").attr("jqimg");$(this).children("img").attr("alt",'');if($("div.zoomdiv").get().length==0){$(this).after("<div class='zoomdiv'><img class='bigimg' src='"+bigimage+"'/></div>");$(this).append("<div class='jqZoomPup'> </div>")}if(settings.position=="right"){ if(imageLeft+imageWidth+settings.offset+settings.xzoom>screen.width){ leftpos=imageLeft-settings.offset-settings.xzoom } else{leftpos=imageLeft+imageWidth+settings.offset}}else{leftpos=imageLeft-settings.xzoom-settings.offset; if(leftpos<0){leftpos=imageLeft+imageWidth+settings.offset}}$("div.zoomdiv").css({top:imageTop,left:leftpos});$("div.zoomdiv").width(settings.xzoom);$("div.zoomdiv").height(settings.yzoom);$("div.zoomdiv").show(); if(!settings.lens){$(this).css('cursor','crosshair')} $(document.body).mousemove(function(e){mouse=new MouseEvent(e);var bigwidth=$(".bigimg").get(0).offsetWidth; var bigheight=$(".bigimg").get(0).offsetHeight; var scaley='x'; var scalex='y'; if(isNaN(scalex)|isNaN(scaley)){var scalex=(bigwidth/imageWidth);var scaley=(bigheight/imageHeight); $("div.jqZoomPup").width((settings.xzoom)/scalex);$("div.jqZoomPup").height((settings.yzoom)/scaley); if(settings.lens){$("div.jqZoomPup").css('visibility','visible')}} xpos=mouse.x-$("div.jqZoomPup").width()/2-imageLeft;ypos=mouse.y-$("div.jqZoomPup").height()/2-imageTop; if(settings.lens){xpos=(mouse.x-$("div.jqZoomPup").width()/2<imageLeft)?0:(mouse.x+$("div.jqZoomPup").width()/2>imageWidth+imageLeft)?(imageWidth-$("div.jqZoomPup").width()-2):xpos;ypos=(mouse.y-$("div.jqZoomPup").height()/2<imageTop)?0:(mouse.y+$("div.jqZoomPup").height()/2>imageHeight+imageTop)?(imageHeight-$("div.jqZoomPup").height()-2):ypos} if(settings.lens){$("div.jqZoomPup").css({top:ypos,left:xpos})}scrolly=ypos;$("div.zoomdiv").get(0).scrollTop=scrolly*scaley;scrollx=xpos;$("div.zoomdiv").get(0).scrollLeft=(scrollx)*scalex})}, function(){$(this).children("img").attr("alt",noalt); $(document.body).unbind("mousemove"); if(settings.lens){$("div.jqZoomPup").remove()} $("div.zoomdiv").remove()}); count=0; if(settings.preload){$('body').append("<div style='display:none;' class='jqPreload"+count+"'>sdsdssdsd</div>"); $(this).each(function(){ var imagetopreload=$(this).children("img").attr("jqimg"); var content=jQuery('div.jqPreload'+count+'').html(); jQuery('div.jqPreload'+count+'').html(content+'<img src=\"'+imagetopreload+'\">')})}}})(jQuery);function MouseEvent(e){this.x=e.pageX;this.y=e.pageY}</script><script type="text/javascript"> $(document).ready(function(){ $(".jqzoom").jqueryzoom({ xzoom:300, // 放大图的宽 yzoom:300, // 放大图的高 offset:30, // 放大图距离原图的位置 position:'right' // 放大图在原图的右边(默认为right) }); });</script></head><body> <div> <div class="jqzoom"> <img src="images/room_small.jpg" alt="房间演示" jqimg="images/room_big.jpg" /> </div> </div> </body></html> 有呀,有现成的。你到这个地址下载:http://www.51mdq.com/shop/order/para_10006_230_P104240.html下载两个文件:<script type="text/javascript" src="/js/MagicZoom.js"></script><link href="/style/MagicZoom.css" type="text/css" rel="Stylesheet" />这两个文件下载后,导入你当前页面,用的时候很简单:<a href='大图URL地址' class="MagicZoom" target="_blank"><img src="小图URL地址" alt="" /></a> 看看:http://www.cnblogs.com/sohighthesky/archive/2009/11/15/imagezoom.html javaEE学习路线 谁给看看 这个服务端的代码是怎么实现的? 超级困惑,谁知道淘宝网鼠标移动到图片会放大是怎么实现的?? 一个超链接打开两个网址 〖求一段 Javascript 代码〗: 打开一个页面, 查找某个链接的地址, 再打开其指向的内容. 问下下,javascript中动态生成的表格怎么控制位置? 怎样验证用户输入的颜色值是否正确? 大家帮忙看看我的正则表达哪里写错啦 高手们,帮帮忙!!!马上结贴 如何屏蔽掉超链接的地址 js如何移动iframe里的页面位置 提供验证URL的正则表达式~~~~~~~大虾们帮忙测试和改进!
可以参考这个
$("#mycarousel li").mouseover(function(){
$("#Product_BigImage img")[0].src="http://img10.360buyimg.com/S1/"+this.getElementsByTagName("img")[0].name;
$("#Product_BigImage img")[0].jqimg="http://img10.360buyimg.com/S0/"+this.getElementsByTagName("img")[0].name;
$(this).siblings().each(function(){
this.getElementsByTagName("img")[0].className="";
})
this.getElementsByTagName("img")[0].className="curr"; })
};
主要是用到jQuery的mouseover和each两个函数。前者就不用说了。后者主要是再document ready时给一组COM控件添加mouseover事件。可以完全把图片都定义在css里面。这里只是再mouseover时给上面那个大图显示区换css就OK了。
我不是script高手,就是希望能帮到你。呵呵
<TABLE>
<TR>
<TD><img id="bigpic" src="http://img10.360buyimg.com/S1/4633/67599a06-edbc-4a07-87a2-8a6db67eb7b3.jpg" border="1"></TD>
</TR>
<TR>
<TD>
<img src="http://img10.360buyimg.com/S5/4633/67599a06-edbc-4a07-87a2-8a6db67eb7b3.jpg" border="0" onmouseover="big(this)">
<img src="http://img10.360buyimg.com/S5/3474/8d7b3df9-c57c-424e-8805-004b2c2bb819.jpg" border="0" onmouseover="big(this)">
<img src="http://img10.360buyimg.com/S5/2585/aef504c7-31af-41af-90ba-7c48e4e17682.jpg" border="0" onmouseover="big(this)">
<img src="http://img10.360buyimg.com/S5/443/8fd17e13-a911-4b64-97f1-e49395a028ab.jpg" border="0" onmouseover="big(this)">
<img src="http://img10.360buyimg.com/S5/2918/61e6ef8f-22fc-4d1d-ae6c-d173cb0ff3d5.jpg" border="0" onmouseover="big(this)">
</TD>
</TR>
</TABLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function big(obj){
bigpic.src = obj.src.replace("S5","S1");
}
//-->
</SCRIPT>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>放大镜效果</title>
<link href="css/jqzoom.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
(function($){$.fn.jqueryzoom=function(options)
{var settings={xzoom:200,yzoom:200,offset:10,position:"right",lens:1,preload:1};
if(options){$.extend(settings,options)}
var noalt='';$(this).hover(function(){var imageLeft=$(this).offset().left;
var imageTop=$(this).offset().top;
var imageWidth=$(this).children('img').get(0).offsetWidth;
var imageHeight=$(this).children('img').get(0).offsetHeight;noalt=$(this).children("img").attr("alt");
var bigimage=$(this).children("img").attr("jqimg");
$(this).children("img").attr("alt",'');
if($("div.zoomdiv").get().length==0){$(this).after("<div class='zoomdiv'><img class='bigimg' src='"+bigimage+"'/></div>");
$(this).append("<div class='jqZoomPup'> </div>")}
if(settings.position=="right"){
if(imageLeft+imageWidth+settings.offset+settings.xzoom>screen.width){
leftpos=imageLeft-settings.offset-settings.xzoom
}
else{leftpos=imageLeft+imageWidth+settings.offset}
}
else{leftpos=imageLeft-settings.xzoom-settings.offset;
if(leftpos<0){leftpos=imageLeft+imageWidth+settings.offset}
}
$("div.zoomdiv").css({top:imageTop,left:leftpos});
$("div.zoomdiv").width(settings.xzoom);
$("div.zoomdiv").height(settings.yzoom);
$("div.zoomdiv").show(); if(!settings.lens){$(this).css('cursor','crosshair')} $(document.body).mousemove(function(e){mouse=new MouseEvent(e);var bigwidth=$(".bigimg").get(0).offsetWidth; var bigheight=$(".bigimg").get(0).offsetHeight; var scaley='x'; var scalex='y'; if(isNaN(scalex)|isNaN(scaley)){var scalex=(bigwidth/imageWidth);var scaley=(bigheight/imageHeight); $("div.jqZoomPup").width((settings.xzoom)/scalex);$("div.jqZoomPup").height((settings.yzoom)/scaley); if(settings.lens){$("div.jqZoomPup").css('visibility','visible')}} xpos=mouse.x-$("div.jqZoomPup").width()/2-imageLeft;ypos=mouse.y-$("div.jqZoomPup").height()/2-imageTop; if(settings.lens){xpos=(mouse.x-$("div.jqZoomPup").width()/2<imageLeft)?0:(mouse.x+$("div.jqZoomPup").width()/2>imageWidth+imageLeft)?(imageWidth-$("div.jqZoomPup").width()-2):xpos;ypos=(mouse.y-$("div.jqZoomPup").height()/2<imageTop)?0:(mouse.y+$("div.jqZoomPup").height()/2>imageHeight+imageTop)?(imageHeight-$("div.jqZoomPup").height()-2):ypos} if(settings.lens){$("div.jqZoomPup").css({top:ypos,left:xpos})}scrolly=ypos;$("div.zoomdiv").get(0).scrollTop=scrolly*scaley;scrollx=xpos;$("div.zoomdiv").get(0).scrollLeft=(scrollx)*scalex})}, function(){$(this).children("img").attr("alt",noalt);
$(document.body).unbind("mousemove"); if(settings.lens){$("div.jqZoomPup").remove()} $("div.zoomdiv").remove()});
count=0;
if(settings.preload){$('body').append("<div style='display:none;' class='jqPreload"+count+"'>sdsdssdsd</div>");
$(this).each(function(){
var imagetopreload=$(this).children("img").attr("jqimg");
var content=jQuery('div.jqPreload'+count+'').html();
jQuery('div.jqPreload'+count+'').html(content+'<img src=\"'+imagetopreload+'\">')})}}})(jQuery);function MouseEvent(e){this.x=e.pageX;this.y=e.pageY}
</script>
<script type="text/javascript">
$(document).ready(function(){
$(".jqzoom").jqueryzoom({
xzoom:300, // 放大图的宽
yzoom:300, // 放大图的高
offset:30, // 放大图距离原图的位置
position:'right' // 放大图在原图的右边(默认为right)
});
});
</script></head>
<body>
<div>
<div class="jqzoom">
<img src="images/room_small.jpg" alt="房间演示" jqimg="images/room_big.jpg" />
</div>
</div>
</body>
</html>
你到这个地址下载:http://www.51mdq.com/shop/order/para_10006_230_P104240.html
下载两个文件:
<script type="text/javascript" src="/js/MagicZoom.js"></script>
<link href="/style/MagicZoom.css" type="text/css" rel="Stylesheet" />
这两个文件下载后,导入你当前页面,用的时候很简单:
<a href='大图URL地址' class="MagicZoom" target="_blank"><img src="小图URL地址" alt="" /></a>