手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery实现鼠标滑过小图时显示大图的方法
jquery实现鼠标滑过小图时显示大图的方法
摘要:本文实例讲述了jquery实现鼠标滑过小图时显示大图的方法。分享给大家供大家参考。具体实现方法如下:复制代码代码如下:li{list-sty...

本文实例讲述了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实现鼠标滑过小图时显示大图的方法】相关文章:

JavaScript实现文本框中默认显示背景图片在获得焦点后消失的方法

jQuery实现dialog设置focus焦点的方法

js实现键盘Enter键提交表单的方法

jQuery实现给页面换肤的方法

js实现字符串转日期格式的方法

js判断鼠标位置是否在某个div中的方法

jquery实现的判断倒计时是否结束代码

javascript实现图片跟随鼠标移动效果的方法

Jquery实现动态切换图片的方法

jQuery实现转动随机数抽奖效果的方法

精品推荐
分类导航