2013-10-29 5 views
0

아래 코드가 왜 잘못 실행되고 있는지 알고 싶습니다. 체크하지 않은 함수를 실행하는 체크 박스가 있습니다. 그러나 내가 클릭 할 때마다 0.4 초 이하로 빨리 클릭하면 실패합니다. 내 배열에 값이 중복되었습니다.자바에서 동시 발생 이벤트

HTML

<input type="checkbox" id="uni2198" name="uni" value="2198" onclick="Uncheck('2198')"> 

JS

unidadesSelecionadas = {}; 
function Uncheck(id) {    
    var idSelect = '#uni' + id; 

    if ($(idSelect).is(':checked')) {     
     if ($.inArray(parseInt(id), unidadesSelecionadas) == -1) { 
      unidadesSelecionadas.push(id);   
     } 
    } else { 
     unidadesSelecionadas.splice($.inArray(parseInt(id), unidadesSelecionadas), 1);  
    } 
} 

답변

0

사용 onchange를 대신 onclick을 볼 :

<input type="checkbox" id="uni2198" name="uni" value="2198" onchange="Uncheck('2198')"> 
+0

감사를 신속하게 되. 그것은 작동합니다! – Gandarez