사용자 클릭시 입력 유효성 검사를 수행하려고합니다. 그러나 jQuery click() 함수는 일관성없이 작동합니다. 때로는 예상대로 작동하지만 때때로 링크를 클릭해도 화면 상단으로 뷰포트를 이동하는 것 외에는 아무 것도하지 않습니다. 문제는 일관되게 오류를 복제 할 수 없다는 것입니다. 때로는 효과가 있고 때때로 그렇지 않습니다. 필자는 Windows XP의 Firefox와 Mac의 Chrome 9.0에서 모두 재현 해 냈지만 때로는 페이지가 작동하고 때로는 그렇지 않을 수도 있습니다. 한 번 잘못로드했을 때 캐시를 지우고 페이지를 다시로드하려고 시도했지만 페이지가 여전히로드되지 않았습니다. 특히 파일을 크게 변경 한 후에는 로딩하지 않는 것에서 로딩하는 것으로 나타납니다.jquery click() working inconsistently
여기에 축소 된 테스트 케이스를 설정합니다 : http://kburke.org/thesis/consentform1.php. 양식이 올바르게 작동하면 경고 상자가 표시됩니다.
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#submitlink").click(function(){
console.log("link clicked");
alert("Clicked!");
});
console.log("loading...");
});
</script>
</head>
<body style="width:35em; margin-bottom:200px;">
<input type="text" value="" name="part_name" id="name1" />
<input type="text" value="" name = "part_name2" id="name2" />
<input type="checkbox" name="accept_1" id="accept_1" />I signify my agreement that all matters and issues mentioned above have been discussed to my satisfaction and agreement. <br><br>
<input type="checkbox" name="accept_2" id="accept_2" />I acknowledge that I am 18 years of age or older on the date of signing this consent, and that I have read and understood all of the above.</p>
<div id="submitlink" style="float:right; color:blue; text-decoration:underline; cursor:pointer;">I agree</div>
<form method="post" id="agree" action="/thesis/instructions.php">
<input type="hidden" name="id" id="nextpage" value="">
<input type="hidden" name="name" id="the_name" value="" />
</form>
</body>
</html>
가 나는 행동이 일치하지 않는 특히 것을 당황하고, 당신이 가진 수있는 통찰력을 주셔서 감사합니다 : 여기에 코드입니다.
편집 :console.log
이 문제를 일으키는 것으로 제안되었지만 콘솔 진술을 제거한 후에도 문제가 계속되고 있습니다. Chrome의 JS 디버거를 실행하면 문제가 발생했을 때 $("#submitlink")
호출 내의 코드가 전혀 실행되지 않고 있음을 알 수 있습니다. 늘 그렇듯이 도와 주셔서 감사합니다.
오류를 생산하는 전체 페이지가 여기에 있습니다 : http://kburke.org/thesis/consentform.php 페이지 –
링크가 내 크롬에서 잘 작동합니다. .. – Lukman
나에게 맞는 현재 버전 (작동하지 않는 곳)은 Mac의 Chrome 7.0입니다. 나는 또한 가능한 가장 작은 경우로 줄 였지만 아직도 나를 위해 일하지 않는다. –