Listen to double click not click

前端 未结 6 2043
情歌与酒
情歌与酒 2020-12-15 08:55

I\'m just wondering why click event happening when I dbclick an element?

I have this code:(JSBIN)

HTML

&l         


        
6条回答
  •  半阙折子戏
    2020-12-15 09:29

    dblclick is not magical: though the second rapid click fires the dblclick event, the first click has already triggered its own event handler.

    You should pretty much never set both a click and a dblclick event on a DOM element; when you do, you'll need fancy tricks with timers to mitigate the issue.

    In this specific scenario, you'll also need to fix your typo (s/dbclick/dblclick/) to get the event to fire at all.

    Also note that dblclick is not actually part of the DOM specification at all (not present in DOM Level 2 1.6.2). For this reason it's known as a "DOM Level 0" feature.

提交回复
热议问题