편집 : 죄송합니다. 죄송합니다. 더 간단한 테스트를 통해 문제점을 좁혀 봤지만 괄호가 없어서 실패했습니다. 원래 실패 코드 내가 가진 :if-else 테스트의 경고가 작동하지 않습니다 - 초보자
<script type="text/javascript">
var element = document.getElementById('description');
var correctTitle = document.getElementById('figureCaption');
element.addEventListener('change', function() {
if (element.value == picTitle) {
alert("success! " + picTitle);
/* var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "/WEB-INF/acceuil.jsp", false,
element.value);
xmlHttp.send(); */
} else { alert("fail! " + picTitle); }
}, false);
</script>
당신은 조건 괄호 누락 : http://www.w3schools.com/js/js_if_else.asp – NPE
문은 할 필요가있는 경우 - (참)' – exexzian
@NPE은 W3 스쿨을 사용하지 마십시오 경우를' . http://www.w3fools.com/ 여기 MDN이 있습니다 : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else – Hogan