jquery: open link on doubleclick?

感情迁移 提交于 2019-12-06 05:57:37

问题


i wonder if this is the best solution?

    $('.folder a').click(function(e) {
  e.preventDefault();
});

$('.folder a').dblclick(function(e) {
    window.location.replace($(this).attr("href"));
});

it's working! would you do it in a different manner?


回答1:


Nope that's perfect.




回答2:


What you're doing works and is fine technically.

The issue is with the UI. Double-clicking on a hyperlink is not intuitive behaviour. Particularly when disabling the click behaviour. I would suggest a more intuitive UI.




回答3:


Yes, a slightly different manner.

$('.folder a').click(function(e) {
    e.preventDefault();
}).dblclick(function() {
    window.location.replace($(this).attr("href"));
});

Actually I'd use .on('click') and .on('dblclick') but in either case they would be chained as above.



来源:https://stackoverflow.com/questions/3243554/jquery-open-link-on-doubleclick

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!