jquery: open link on doubleclick?
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.
精彩评论