JavaScript document的使用2

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="js/test.js" type="text/javascript" charset="utf-8"></script>
</head>
<body style="height: 3000px;">
<button onclick="func()">按钮</button>
<div id="box" style="width: 100px;height: 200px;background-color: red"></div>
<script type="text/javascript">

 var jsDiv = document.getElementById("box")
    function func(){
        jsDiv.style.backgroundColor="yellow"
    }
</script>

</body>
</html>

 

posted @ 2018-12-28 23:26  freeengles  阅读(154)  评论(0编辑  收藏  举报