菜鸟请教为何这样不输出结果呢
程序代码:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS测试</title> <style type="text/css"> #zuoyemingdan { width: 10rem; height: 20rem; font-size: 11px; } #lab{ display: block; } #zuoyemingdan{ display: block; } #result{ position:absolute; font-size: 11px; width: 10rem; height: 20rem; right:200px; top: 8px; } </style> </head> <body> <div id="div1"> <textarea rows="" cols="" id="zuoyemingdan" placeholder="请输入已交作业名单"></textarea> </div> <div id="div2" > <textarea rows="" cols="" id = result></textarea> </div> <br> <button onclick="myFunction()">开始检查作业</button> <script type="text/javascript"> function myFunction() { var banji=["钟瑞秋",""]; var name=""; var x = ""; var txt = document.getElementById('zuoyemingdan').value; for (name in txt){ alert(name) if (name.indexOf(banji)) { x += name + ' '; docment.getElementById('result').innerHTML=x; } } } </script> </body> </html>
[此贴子已经被作者于2021-9-28 21:58编辑过]