开发者

jquery: open link on doubleclick?

开发者 https://www.devze.com 2023-01-07 10:02 出处:网络
i wonder if 开发者_开发技巧this is the best solution? $(\'.folder a\').click(function(e) { e.preventDefault();

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?


Nope that's perfect.


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.


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.

0

精彩评论

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