本文实例为大家分享了Jquery实现图片跟随效果的具体代码,供大家参考,具体内容如下 实现效果 要实现的功能: * 鼠标进来,显示大图片; * 鼠标出去,隐藏大图片; * 鼠标在大
本文实例为大家分享了Jquery实现图片跟随效果的具体代码,供大家参考,具体内容如下
要实现的功能:
* 鼠标进来,显示大图片;
* 鼠标出去,隐藏大图片;
* 鼠标在大图片里边动,大图片跟着动。
<html>
<head>
<meta Http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/CSS">
body {
text-align: center;
}
#small {
margin-top: 150px;
}
#showBig {
position: absolute;
display: none;
}
</style>
<script type="text/javascript" src="script/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function(){
//给小图片绑上事件
$("#small").bind("mouseover mouseout mousemove",function (event) {
if(event.type == "mouseover"){
$("#showBig").show();
} else if (event.type == "mouseout"){
$("#showBig").hide();
} else if(event.type == "mousemove"){
console.log(event);
$("#showBig").offset({
left: event.pageX + 10,
top: event.pageY + 10
});
}
});
});
</script>
</head>
<body>
<img id="small" src="img/small.jpg" />
<div id="showBig">
<img src="img/big.jpg">
</div>
</body>
</html>
--结束END--
本文标题: jQuery实现图片跟随效果
本文链接: https://www.lsjlt.com/news/133024.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0