开发者

prevent browser from generating double click event

I have two overlapping div elements in my web app.

On the underlying div an event is registered on double click.

On the div that lies above the other div a event is registered on click that hides the div.

The problem is 开发者_如何学Cthat if I double click on the above div element it is hidden after the first click BUT the second click causes the double click event on the underlying div to fire - how can I prevent that?


Mixing "click" and "double-click" is going to be problematic at best. However, in this case things might get better if you just ensure that your handler for the "click" event (the event that hides the element) returns false to the browser.

How to do that depends on how your handler is registered. If it's like this:

<div onclick='hideMe();'>

then you'd change that to

<div onclick='hideMe(); return false'>

If you're using some framework or some other means of attaching the handler, then just having the handler function return false should do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜