toggle on double click

冷暖自知 提交于 2020-01-06 13:51:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!