双击切换

时间:2011-05-28 06:55:41

标签: jquery toggle double-click

想办法在doubleclick上进行切换,这是我的代码:

$('#mydiv').toggle(function() {
  $('#post').css({'height' : '188'});
}, function() {
  $('#post').css({'height' : '48'});
});     

2 个答案:

答案 0 :(得分:2)

$('#mydiv').dblclick(function () {
  $('#post').height($('#post').height() > 100 ? 48 : 180);
});

或者你可能想要这个:

$(".generic-expand-button").each(function () {
    $(this).dblclick(function() {
        $(this).closest(".post").height($(this).closest(".post").height() > 100 ? 48 : 180);
    });
});

答案 1 :(得分:1)

使用jQuery双击事件:http://api.jquery.com/dblclick/

相关问题