我有一組單選按鈕我的網頁上是這樣的:切換組一起
ALL (x) On () Off OPTION 1 (x) On () Off OPTION 2 (x) On () Off OPTION 3 (x) On () Off OPTION 4 (x) On () Off
當您檢查開或關單選按鈕,「所有」,它設置的所有其他單選按鈕相同的設置:
var autoPostAllOn = $('#auto-post-all-on'); var autoPostAllOff = $('#auto-post-all-off'); var fbPostToggleOn = $('.fb-post-toggle-on'); var fbPostToggleOff = $('.fb-post-toggle-off'); $(autoPostAllOn).click(function(){ $(fbPostToggleOn).attr('checked', 'checked'); }); $(autoPostAllOff).click(function(){ $(fbPostToggleOff).attr('checked', 'checked'); });
不過,我也希望做相反的:例如,如果用戶手動檢查全部關閉按鈕,自動檢查關按鈕「全部」過。我會如何去做這件事?
完美!謝謝。 – daGUY 2012-03-22 15:44:10