双击切换 [英] toggle on double click

查看:95
本文介绍了双击切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一种在doubleclick上进行切换的方法,这是我的代码:

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'});
});     

推荐答案

$('#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);
    });
});

这篇关于双击切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆