document.write清除页面
为什么在下面的代码中,document.write
在函数调用时,validator()
表单元素(复选框和按钮)将从屏幕中删除?
<!DOCTYPE html><html> <head> <script type="text/javascript"> function validator() { if (document.myForm.thebox.checked) document.write("checkBox is checked"); else document.write("checkBox is NOT checked"); } </script> </head> <body> <form name="myForm"> <input type="checkbox" name ="thebox"/> <input type="button" onClick="validator()" name="validation" value="Press me for validation"/> </form> </body></html>
跃然一笑
ABOUTYOU