عندما تكون مبتدئًا في JavaScript ، فإنك تتعرض دائمًا للتعذيب بسبب مشاكل صغيرة جدًا لفترة طويلة كل يوم ، وستكون هناك العديد من المشكلات الصغيرة الليلة.
أولاً: استخدم اقتباسات مزدوجة جميعها للتسبب في مطابقة الأخطاء
<type type = "checkbox" onMouseover = "document.getElementById (" test "). style.display =" none ":"/>تم الإبلاغ عن الخطأ عند تغيير الوظيفي: Toke غير المتوقع "}". راجعت لفترة طويلة ولم أجد أي أخطاء. لقد وجدت أن الفيديو كان مليئا مع اقتباسات واحدة.
<type type = "checkbox" onMouseover = "document.getElementById ('test'). style.display =" none ":"/>بعد التغيير إلى اقتباسات واحدة ، تم التخلص من الخطأ أخيرًا ، مما أزعجني طوال الليل. . إرفاق الرابط http://www.cnblogs.com/chinabc/archive
ثانياً: إضافة فاصلة فاصلة عن طريق الخطأ
<div id = "test" onMouseover = "Toyellow ()" ؛ onMouseout = "tored ()" ؛> تغيير </div>
اكتب فاصلة فاصلة إضافية ، مما أدى
ثالثًا: اكتب المزيد من الأقواس بعد اسم الوظيفة
<script> function toyellow () {document.getElementById ("test"). className = "Test2" ؛ } وظيفة tored () {document.getElementById ("test"). className = "Test1" ؛ } document.getElementById ("test"). onMouseover = toyellow () ؛ document.getElementById ("test"). onMouseout = tored () ؛ </script>ولكن بعد إزالة الأقواس بعد toyellow () و tored () ، سيتم تنفيذها بشكل طبيعي
الرابع: تعديل السمة التي تم فحصها من مربع الاختيار
استخدم ثلاثة أزرار لتحقيق اختيار مربع الاختيار واختياره.
<! doctype html> <html> <head> <meta charset = "utf-8"> </title> </head> <body> <button id = "btn"> حدد الكل </button> <button id = "nobtn"> ليس كل شيء </button> /> <input type = "checkbox" /> <input type = "checkbox" /> <input type = "checkbox" /> <input type = "checkbox" /> <input type = "checkbox" /> <type type = "checkbox" /> <input type = "input type = "checkbox" /> <type type = "checkbox" /> <input type = "checkbox" /> <input type = "checkbox" /> <input type = "checkbox" /> <input type = "checkbox" /> <input type = "chectbox" /> <input type = "checkbox" /> 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 anverse = document.getElementById ("عكسي") ؛ عكسي. } آخر {input [i] .checked = false ؛ }}} </script> </body> </html>سيتحدث المقالة أعلاه عن أخطاء وحلول JavaScript المشتركة. هذا هو كل المحتوى الذي شاركته معك. آمل أن تتمكن من إعطائك مرجعًا وآمل أن تتمكن من دعم wulin.com أكثر.