Jquery: open doubleclick link?

Interestingly, is this the best solution?

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

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

it works! would you do it differently?

+3
source share
3 answers

No, that's perfect.

+4
source

What you do works perfectly technically.

The problem with the user interface. Double-clicking on a hyperlink is not an intuitive behavior. In particular, when disabling click behavior. I would suggest a more intuitive interface.

+1
source

Yes, a little different.

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

In fact, I would use .on('click')and .on('dblclick'), but in any case, they would be shackled as described above.

0
source

Source: https://habr.com/ru/post/1754543/


All Articles