Home >Web Front-end >HTML Tutorial >学习JS遇到的问题_html/css_WEB-ITnose

学习JS遇到的问题_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 08:46:361264browse

  • 关于document.body.innerHTML

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>tit</title>    <style type="text/css">        div{width: 30px;height: 30px;font-size: 12px;color: #fff;background: red;line-height: 30px;text-align: center;position: absolute;}    </style>    <script type="text/javascript">        window.onload=function(){            var oDiv=document.getElementsByTagName('div');            var oBtn=document.getElementsByTagName('input');            var m=0;            oBtn[0].onclick=function(){                    for(i=0;i<9;i++){                        document.body.innerHTML+='<div>'+i+'</div>';                    }            }        }    </script></head><body>    <input type="submit"value='按钮' name=""></body></html>

再次点击按钮,按钮无效的原因:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn