问题
looking a way to make a toggle on doubleclick, this is my code:
$('#mydiv').toggle(function() {
$('#post').css({'height' : '188'});
}, function() {
$('#post').css({'height' : '48'});
});
回答1:
$('#mydiv').dblclick(function () {
$('#post').height($('#post').height() > 100 ? 48 : 180);
});
Or may be you want this:
$(".generic-expand-button").each(function () {
$(this).dblclick(function() {
$(this).closest(".post").height($(this).closest(".post").height() > 100 ? 48 : 180);
});
});
回答2:
Use jQuery double click event: http://api.jquery.com/dblclick/
来源:https://stackoverflow.com/questions/6160150/toggle-on-double-click