Windows 上 Chrome/Safari 中的 Jquery mousedown mouseup
我创建了一个可以用鼠标滚动的页面,就像谷歌地图一样,但是当用户单击一个对象时,我希望它显示隐藏的东西,我想出了一个非常简单的解决方案:
var clicking = false;
//mouse clicked down
$(".tile").mousedown(function () {
clicking = true;
});
//if mousemoves whilst its clicked down dont do mouse up as we are scrolling page
$(".tile").mousemove(function () {
if (clicking == true) {
clicking = false;
}
});
//So if mouse hasnt moved show the hidden object
$(".tile").mouseup(function () {
if (clicking == true) {
//Show the hidden thing
}
}
这适用于所有Windows 上除了 chrome 和 safari 之外还有哪些浏览器?那么也许与 webkit 有关?如果我在这些浏览器中双击,它就可以工作,但如果我单击一次,它会更喜欢。我想知道是否有人遇到过这个问题或知道解决方案?希望这是有道理的。
谢谢
I have created a page that can scroll with the mouse, like google maps, but when the user does a single click on an object, i want it to show something hidden, i have come up with a very simple solution:
var clicking = false;
//mouse clicked down
$(".tile").mousedown(function () {
clicking = true;
});
//if mousemoves whilst its clicked down dont do mouse up as we are scrolling page
$(".tile").mousemove(function () {
if (clicking == true) {
clicking = false;
}
});
//So if mouse hasnt moved show the hidden object
$(".tile").mouseup(function () {
if (clicking == true) {
//Show the hidden thing
}
}
This works in all browsers apart from chrome and safari on windows? so maybe something to to with webkit? It works if i double click in these browsers but would prefer if its a single click. I was wondering if anyone has come across this problem or knows of a solution? Hope this makes sense.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
mousedown 或 mouseup 在所有浏览器中都能完美工作,包括 Windows 上的 chrome 和 safari
,如果不适合您,请使用最后的 jQuery,也可以尝试:
mousedown OR mouseup work perfectly in all browsers include chrome and safari on windows
if not work for you, use last jQuery,also try :