2012-09-13 5 views
0

다음 코드가 있습니다.IE7에서 객체 지향 자바 스크립트 코드가 작동하지 않습니다.

function radioButtons() { 

var _inputCount; 
var _inputParentCount; 
var _radioInput; 

return { 

    inputCounter:function(groupId){ 

     _inputCount = $(groupId).find("input"); 
     _inputParentCount = $(_inputCount).parent(); 

     for(i = 0; i < _inputParentCount.length; i++){ 
      $(_inputParentCount[i]).attr("id", groupId + [i]); 
     } 

    }, 

    radioAction:function(radioButton){ 

     _radioInput = $(radioButton).find("input"); 

     for(i = 0; i < _inputCount.length; i ++){ 

      $(_inputCount[i]).parent().removeClass("selected"); 
      $(_inputCount[i]).attr("value", "false"); 

     } 


     $(radioButton).addClass("selected"); 
     $(_radioInput).attr("value", "true"); 
    }, 



}; 
}; 

var radioButtonsOne = new radioButtons(); 

$(document).ready(function(){ 
radioButtonsOne.inputCounter("#radioButtonsGroup"); 
}); 

맞춤 라디오 버튼에 대해 작성한 맞춤 기능입니다. 나는 Checkboxes 버튼과 비슷한 것을 가지고있다. IE7을 제외한 모든 브라우저에서 완벽하게 작동합니다. radioButtonsOne이 정의되어 있지 않습니다. 그러나 그것은 그렇다. 왜 그런가?

감사합니다.

+1

이 http://stackoverflow.com/questions/5139205/javascript-can-a-comma-occur-after-the-last- 참조 제거 배열의 가치 집합 – simon

답변

5

변화

$(radioButton).addClass("selected"); 
     $(_radioInput).attr("value", "true"); 
    }, 

,

$(radioButton).addClass("selected"); 
     $(_radioInput).attr("value", "true"); 
    } 
+0

좋은! 사실 IE7은 객체의 마지막 키 다음에 쉼표가 올 때 예외를 throw합니다. – MaxArt

+0

고마워요! 그게 효과가 있었어! 빠른 답변 감사합니다! – Gezzasa

관련 문제