toggle on double click
问题 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