简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

jquery实现鼠标滑过小图时显示大图的方法

来源:易贤网   阅读:1659 次  日期:2015-03-30 14:26:47

温馨提示:易贤网小编为您整理了“jquery实现鼠标滑过小图时显示大图的方法”,方便广大网友查阅!

这篇文章主要介绍了jquery实现鼠标滑过小图时显示大图的方法,涉及图片及鼠标操作的技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了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>

更多信息请查看IT技术专栏

更多信息请查看脚本栏目
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:js实现禁止中文输入的方法
下一篇:使用jquery 简单实现下拉菜单
易贤网手机网站地址:jquery实现鼠标滑过小图时显示大图的方法
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!