실습문제5-1.pdf

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function chColor(){
            var arrColor=["#ff0","#6c0","#fcf","#cf0","39f"];
            var arrNum=Math.floor(Math.random()*  arrColor.length);
            var bodyTag = document.getElementById("theBody");
            bodyTag.style.backgroundColor=arrColor[arrNum];
        }
    </script>
</head>
<body id="theBody">
    <button onclick="chColor();">배경 색상 바꾸기</button>
</body>
</html>