당신이 JavaScript의 초보자 일 때, 당신은 항상 매일 오랫동안 아주 작은 문제로 고문을 당하며, 오늘 밤 몇 가지 작은 문제가있을 것입니다.
첫째 : 이중 인용문을 사용하여 일치 오류를 일으 킵니다
<input type = "checkbox"onmouseover = "document.getElementById ("test "). style.display ="none ":"/>경력을 변경할 때 오류가보고되었습니다 : 예상치 못한 Toke "}". 나는 오랫동안 확인했고 오류를 찾지 못했습니다. 나는 비디오가 단일 따옴표로 채워 졌다는 것을 알았습니다.
<input type = "checkbox"onmouseover = "document.getElementById ( 'test'). style.display ="none ":"/>
단일 인용문으로 변경 한 후 오류가 마침내 제거되어 밤새도록 문제가 발생했습니다. . http://www.cnblogs.com/chinabc/archive/2010/11/19/1881947.html 링크를 첨부하십시오
둘째 : 실수로 세미콜론을 추가합니다
<div id = "test"onmouseover = "toyellow ()"; onmouseout = "tored ()";> Change </div>
여분의 세미콜론을 작성하여 세미콜론이 실행되지 않은 후 코드가 발생합니다.
셋째 : 함수 이름 뒤에 더 많은 괄호를 작성하십시오
<cript> function toyellow () {document.getElementById ( "test"). className = "test2"; } function tored () {document.getElementById ( "test"). className = "test1"; } document.getElementById ( "test"). OnMouseOver = toyellow (); document.getElementById ( "test"). onMouseOut = tored (); </스크립트>그러나 Toyellow () 및 Tored () 이후 브래킷을 제거한 후에는 정상적으로 실행됩니다.
넷째 : 확인란의 확인 된 속성을 수정하십시오
3 개의 버튼을 사용하여 선택, 선택 및 선택 사항을 선택하십시오.
<! docType html> <html> <head> <meta charset = "utf-8"> <title> </title> </head> <body> <button id = "btn"> all </button "> </button"> </button id = "interelect"> <br/<input = "input buty ="input buty </<input "Checkbox" /> <입력 유형 = "Checkbox" /> <입력 유형 = "checkbox" /> <입력 유형 = "Checkbox" /> <입력 유형 = "checkbox" /> <input bype = "checkbox" /> <입력 유형 = "checkbox" /> <input type = "checkbox" /> <input type = "checkbox"intput " />> <input" "input box" /> <input type = "checkbox". <입력 유형 = "확인란" /> <입력 유형 = "확인란" /> <입력 유형 = "확인란" /> <입력 유형 = "확인란" /> <입력 유형 = "checkbox" /> <입력 유형 = "checkbox" /> <입력 유형 = "input type ="checkbox " /> <input box ="int put box ""int put box "" type = "checkbox" /> <cript> var btn = document.getElementById ( "btn"); var input = document.getElementsByTagName ( "input"); btn.onclick = function () {for (var i = 0; i <input.length; i ++) {input [i] .checked = "checked"; }} var nobtn = document.getElementById ( "nobtn"); nobtn.onclick = function () {for (var i = 0; i <input.length; i ++) {input [i] .checked = false; }} var inverse = document.getElementById ( "inverse"); inverse.onclick = function () {for (var i = 0; i <input.length; i ++) {if (input [i] .checked == false) {input [i] .checked = true; } else {input [i] .checked = false; }}} </script> </body> </html>위의 기사는 일반적인 JavaScript 오류 및 솔루션에 대해 이야기합니다. 이것은 내가 당신과 공유 한 모든 콘텐츠입니다. 나는 당신이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.