반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

비전공개미 개발노트

[JavaScript] 배열을 불러와 박스색상 변경하기 본문

프론트엔드/JavaScript

[JavaScript] 배열을 불러와 박스색상 변경하기

비전공개미 2022. 10. 6. 17:45
반응형
SMALL
<!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>arraybox</title>
</head>
<body>
    <div id="colorBox">

    </div>
    <script>
        let colors = ["red","orange","yellow","green","blue","navy","purple","white","black","lime","gray","pink","aqua","silver","magenta","lightblue","yellowgreen"];

        var data = "";
        for(let i=0; i<colors.length; i++){
            data += "<div style='width:100px; height:100px; float:left; background-color:"+ colors[i]+"'>"+colors[i]+"</div>"
        }
        document.write(data);
    </script>
</body>
</html>
arraybox
반응형
LIST
Comments