问题
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