纵有疾风起
人生不言弃

jQuery 获取鼠标在图片上的坐标

$('#myImage').click(function(event){    //获取鼠标在图片上的坐标     console.log('X:' + event.offsetX+'\n Y:' + event.offsetY);     //获取元素相对于页面的坐标     console.log('X:'+$(this).offset().left+'\n Y:'+$(this).offset().top);});

文章转载于:https://www.jianshu.com/p/248f22d52a54

原著是一个有趣的人,若有侵权,请通知删除

未经允许不得转载:起风网 » jQuery 获取鼠标在图片上的坐标
分享到: 生成海报

评论 抢沙发

评论前必须登录!

立即登录