2012-09-18 69 views
0

我有2個單選按鈕,「是」按鈕啓動「速度計」的旋轉,我想基本上撤消「是」按鈕做了什麼,如果他們決定按「否」後事實。我不能完全弄清楚這方面的最佳方法。取消選擇廣播和撤消動畫

我試圖用這個代碼要做到這一點,它不會引發自定義事件:

jQuery('input[value="Yes"]').bind('click', function(){ 
     jQuery('input[name="' + jQuery(this).attr('name') + '"]').not(jQuery(this)).trigger('deselect');}); 
     jQuery('input[value="yes"]').bind('deselect', function(){ 
      jQuery('#progress').animate(
      { 
       marginBottom: '-=5' 
      },{ 
       step: function(now, fx) { 
        jQuery(this).css({transform: 'rotate(' + now + 'deg)'}); 
      } 
}); }); 

這裏的小提琴: http://jsfiddle.net/pTkkS/12/

+0

是否要取消選中所有「測試」單選按鈕? – nmenego

+0

測試按鈕並不是真正的一部分,只是兩組2 – safeasylum

回答

0

你可以做這樣的事情:

$("input[type=radio]").change(function(){ 
     var marginBottom = $("input[type=radio][value=yes]:checked").length * yourConstantForAnimate; 
    }); 
+0

您是否試圖動態改變邊距? – safeasylum

+0

我試過使用這個,所有我得到的是不能調用對象[對象對象]的長度,但我認爲這是一個好主意 – safeasylum

+0

我沒有時間對你的代碼進行測試。我認爲如果您想要動態調整您的速度計,您要查找的是對此代碼的改進方法。 – scottmgerstl