2011-05-28 64 views
0

尋找一種方法,使上雙擊一個切換,這是我的代碼:切換上雙擊

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

回答

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); 
    }); 
}); 
+0

這有效,但我正在尋找一種方式來處理更多的選擇器,任何新的想法?提前致謝。 – greenbandit 2011-05-28 07:14:08

+0

更多選擇器...在$('#mydiv .toggle-buttons') - > toggle(「#post-」+ somethingDynamicallyCalculated)''中? – 2011-05-28 09:10:32

+0

nope,雙擊,我需要修改更多#,在此先感謝。 – greenbandit 2011-05-28 16:31:47