jquery
  • radio-button
  • 2013-03-15 52 views 0 likes 
    0

    有一個收音機的形式,我穿着jquery和CSS。現在我想對它做更多的jquery,但是當我運行這兩個代碼時,一旦收音機被選中,li就不會關閉。一旦你點擊無線電比特,李應該關閉。還需要告訴它執行以下操作:使用input = name「radio_selected」選擇無線電交換機。這樣隱藏的li中選定的無線電將移出隱藏的li和交換位置,並且不會隱藏在頁面上。上午我瞄準一個對象

    $("input[name='domain_ext']").each(function() { 
         $("#radio_select").attr('checked', 'checked'); 
         var lbl = $(this).parent("label").text(); 
         if ($(this).prop('checked')) { 
          $(this).hide(); 
          $(this).after("<div class='radioButtonOn'>" + lbl + "</div>"); 
         } else { 
          $(this).hide(); 
          $(this).after("<div class='radioButtonOff'>" + lbl + "</div>"); 
         } 
        }); 
    
        $("input[type=radio]").change(function() { 
         $(this).siblings('.radioButtonOff').add('.radioButtonOn').toggleClass('radioButtonOff radioButtonOn'); 
        }); 
    
    
    
        $('div.ribbonBoxarrow').click(function() { 
          $('.ribbonBoxarrow li').show('medium'); 
          return false; 
         }); 
    // once you leave the div (which is contained in the above li hide. 
         $('.ribbonBoxtab').mouseleave(function() { 
          $('.ribbonBoxarrow li').hide('slow'); //missing . 
          return false; 
         }); 
    //if a radio buttn is clicked the hide li 
         $("input[name='domain_ext']").click(function() { //changed .each to .click 
          $('.ribbonBoxarrow li').hide('slow'); //missing . 
          return false; 
         }); 
    
    +0

    刪除警報(火),只是用測試是否工作而不是 – alwayslearning 2013-03-15 01:38:19

    回答

    1
    $("input[name='domain_ext']").each(function() { 
         $("#radio_select").attr('checked', 'checked'); 
         var lbl = $(this).parent("label").text(); 
         if ($(this).prop('checked')) { 
          $(this).hide(); 
          $(this).after("<div class='radioButtonOn'>" + lbl + "</div>"); 
         } else { 
          $(this).hide(); 
          $(this).after("<div class='radioButtonOff'>" + lbl + "</div>"); 
         } 
        }); 
    
        $("input[type=radio]").change(function() { 
         $(this).siblings('.radioButtonOff').add('.radioButtonOn').toggleClass('radioButtonOff radioButtonOn'); 
        }); 
    
    
    
        $('div.ribbonBoxarrow').click(function() { 
          $('.ribbonBoxarrow li').show('medium'); 
          return false; 
         }); 
    // once you leave the div (which is contained in the above li hide. 
         $('.ribbonBoxtab').mouseleave(function() { 
          $('.ribbonBoxarrow li').hide('slow'); //missing . 
          return false; 
         }); 
    //if a radio buttn is clicked the hide li 
         $("input[name='domain_ext']").parent('label').click(function() { //changed .each to .click 
          $('.ribbonBoxarrow li').hide('slow'); //missing . 
          return false; 
         }); 
    
    +0

    $( 「輸入[名稱= 'domain_ext']」)。父( '標籤')。單擊(... 。標籤隱藏輸入從不錯過點擊 – makedon 2013-03-15 02:08:33

    +0

    嘿謝謝你會試試看 – alwayslearning 2013-03-15 07:59:59

    相關問題