본문 바로가기
📝 배우고 익히기 +/바닐라 JS로 크롬 앱 만들기

[바크앱] 9: 6.0-6.2

by 종이빨대 2023. 9. 14.
TOP

목차

    바닐라 JS로 크롬 앱 만들기 (1)

    : Create Chrome App with Vanilla JS → cavjs

    6.0(과제로 미리 시청완료)

    6.1 Background

    - html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Momentum App</title>
        <!-- <link rel="stylesheet" href="css/style.css"> -->
    </head>
    <body>
        <form class="hidden" id="login-form">
            <input required maxlength="15" type="text" placeholder="what is yout name?">
            <button>Log In</button>
            <a href="http://nomadcoders.co">Go to courses</a>
        </form>
        <h1 id="greeting" class="hidden"></h1>
        <h2 id="clock">00:00:00</h2>
        <div id="quote">
            <span></span>
            <span></span>
        </div>
        <!-- <img src="img/0.jpg" alt=""> -->
        <script src="js/clock.js"></script>
        <script src="js/greetings.js"></script>
        <script src="js/quotes.js"></script>
        <script src="js/background.js"></script>
    </body>
    </html>

    -javascript

    const images=["0.jpg","1.jpg","2.jpg"];
    const chosenImage = images[Math.floor(Math.random()*images.length)];
    
    // console.log(images);
    const bgImage =document.createElement("img");
    // console.log(bgImage);
    bgImage.src = `img/${chosenImage}`;
    // console.log(bgImage);
    document.body.appendChild(bgImage);

     

    6.2 Recap

    -