jquery实现鼠标滑过小图时显示大图的方法
作者:bea
本文实例讲述了jquery实现鼠标滑过小图时显示大图的方法。分享给大家供大家参考。具体实现方法如下: 代码如下: <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <title></title> </head> <style type="text/css"> li
本文实例讲述了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程序设计有所帮助。
有用 | 无用
代码如下:
<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中unwrap()方法用法实例
- jquery搜索框效果实现方法
- js表头排序实现方法
- js计算任意值之间随机数的方法
- jquery事件preventDefault()方法用法实例
- jQuery老黄历完整实现方法
- jquery中one()方法的用法实例
- jquery中show()、hide()和toggle()用法实例
- 用js判断是否为360浏览器的实现代码
- jquery果冻抖动效果实现方法
- jquery通过ajax加载一段文本内容的方法
- js实现遮罩层弹出框的方法
- jquery隔行换色效果实现方法
- JavaScript中实现依赖注入的思路分享
- jquery实现textarea输入框限制字数的方法
- jquery单选框radio绑定click事件实现方法
- jquery移动节点实例
- jquery获取checkbox的值并post提交
- 使用jquery 简单实现下拉菜单