问答详情
源自:9-4 区别getElementByID,getElementsByName,getElementsByTagName

任务2把变量定义为J为什么就不行?就取消不了?谢谢

        function checkall(){
            var hobby = document.getElementsByTagName("input");
              for(var i=0; i<hobby.length;i++){
                    
                   hobby[i].checked = true;
                      
                  
                  
              }
          // 任务1

// 任务2 
        }
        function clearall(){
            var hobby = document.getElementsByName("hobby");
     for(var j=0; j<hobby.length;j++){
                    
                   hobby[i].checked = false;
                      
                  
                  
              }
       

提问者:qq_慕沐7463022 2016-04-01 13:27

个回答

  • LeingK
    2016-04-01 14:35:02
    已采纳

    变量不一致,把hobby[i].checked = false;的[i]改成[j]