jquery实现鼠标滑过小图时显示大图的方法
2018-10-12 14:03
597 查看
本文实例讲述了jquery实现鼠标滑过小图时显示大图的方法。分享给大家供大家参考。具体实现方法如下:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title></title>
</head>
<style type="text/css">
li{list-style:none;float:left;margin-left:10px;}
</style>
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
var data = {
"images/11_s.jpg":["images/11_b.jpg","美人1"],
"images/22_s.jpg":["images/22_b.jpg","美人2"],
"images/33_s.jpg":["images/33_b.jpg","美人3"],
"images/44_s.jpg":["images/44_b.jpg","美人4"]
};
$(function(){
$.each(data,function(key,value){
//初始化最后一个div为隐藏
$("div").last().hide();
//创建小图的节点
var smallPath = $("<img src='" + key + "' />").css({"margin":"5px","padding":"2px","border":"1px solid #000"});
//设置大图地址和名称
bigImgPath = smallPath.attr("bigMapPath",value[0]);
bigImgName = smallPath.attr("bigMapName",value[1]);$("div").first().append(smallPath);
//小图上添加事件
smallPath.mouseover(function(){
//最后一个div淡入效果
$("div").last().fadeIn("fast");
//获取大图地址
$("#show").attr("src",$(this).attr("bigMapPath"));
//获取大图名称并设置样式
$("#imgTitle").text($(this).attr("bigMapName")).css({"background":"#ebf1de","padding":"10px","margin-bottom":"10px"});
});
smallPath.mouseout(function(){
$("div").last().fadeOut("fast");
});
});
});
</script>
<body>
<div></div>
<div>
<img id="show" src="" />
</div>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
您可能感兴趣的文章:
相关文章推荐
- jquery实现鼠标滑过小图时显示大图的方法
- jquery实现鼠标滑过小图查看大图的方法
- jquery 的实现鼠标滑过显示大图
- jQuery实现鼠标滑过预览图片大图效果的方法
- jquery实现鼠标滑过小图查看大图的方法
- jQuery实现鼠标悬停显示提示信息窗口的方法
- JQuery 应用: 鼠标滑过td 显示td 的其他内容(方法二)
- jQuery实现鼠标悬停显示提示信息窗口的方法
- jQuery 实现全选全不选,删除选中复选框所在行,鼠标悬停在图片上显示大图
- JQuery鼠标移到小图显示大图效果的方法
- JQuery实现鼠标移动图片显示描述层的方法
- jQuery实现鼠标单击网页文字后在文本框显示的方法
- jQuery实现鼠标滑过图片时会缩小并动态显示信息的幻灯效果
- 分享一个jquery插件:实现类似淘宝上鼠标经过图片右侧显示大图的效果
- jQuery实现鼠标滑过延时显示的效果
- 图片上传生成缩略图,并使用JQuery实现鼠标移动到缩略图显示相应的大图的例子