jquery
  • radio-button
  • 2013-03-15 54 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

    相关问题