jquery图片点击自动翻页实现

本文介绍使用JQuery实现图片点击时自动向上或向下翻页的功能。通过判断鼠标位置来改变图片样式及链接地址,从而实现翻页效果。注意在Chrome浏览器中layerX和layerY属性已废弃。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

采用JQuey要实现图片点击自动向上,向下翻页! 代码:

 

 

$(document).ready(function() {
	$("img").mousemove(function(e){  
		var positionX=e.originalEvent.layerX||e.originalEvent.x||0;
		if(positionX<=$(this).width()/2){           
			 this.style.cursor='url("/image/single/pre.cur"),auto';
			 $(this).attr('title','点击查看上一张');
			 $(this).parent().attr('href','$url&goto=up'); 
		}else{  
			 this.style.cursor='url("/image/single/next.cur"),auto';
			 $(this).attr('title','点击查看下一张');
			 $(this).parent().attr('href','$url&goto=down');
		} 
	});
});
 

 

以上基本实现功能啦!!!

 

付:

 

关于chrome下:

 

 

event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.
 

详细可以访问http://stackoverflow.com/questions/7825448/webkit-issues-with-event-layerx-and-event-layery

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值