커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
똑같이 한 것 같은데ㅠㅠ
undefined주차
북마크
정*윤
댓글
13
추천
0
조회수
37
조회수
37
답변 완료


현 시간이랑 명언 랜덤으로 나오는게 안되네요,,ㅠㅠ 분명 똑같이 한 것 같은데 어디가 문제인지 모르겠어요ㅠㅠㅠ



스파르타 즉문즉답





<!DOCTYPE html>

<html lang="en">


<head>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery.min.js"></script>

    <title>나만의 동기부여 홈화면 만들기</title>


    <script src="index.js"></script>


    <style>


        @import url('https://fonts.googleapis.com/css2?family=poppins:wght@500&display=swap');


        *  {

            font-family: 'poppins', sans-serif;

        }


        body {

            background-image: url("https://4.bp.blogspot.com/-CfXgrQpNcdM/TaC1uePaL4I/AAAAAAAAACs/QO9oSy5VWNE/s1600/0-rome-wallpapers-1024.jpg");

            background-repeat: no-repeat;

            background-size : cover;

            background-position: center;

            width: 100vw;

            height: 80vh;

           

            color: white;


        }


        .time {

                font-size: 120px;

                font-wegiht: bold;

            }


            .greeting {

                font-size: 50px;

            }


            .todo {

                font-size: 20px;

            }


            .author {

                font-size: 25px;

                font-style: italic;

            }


            .main {

                width: 100vw;

                height: 80vh;


                display: flex; flex-direction: column; align-items: center; justify-content: center;


            }


            .quote {

                width: 100vw;

                height: 20vh;

               

                display: flex; flex-direction: column; align-items: center; justify-content: center;

            }


    </style>


    <script>

    </script>

</head>


<body>

    <div class="main">

        <div id="time" class="time">12:00</div>

        <div class="greeting">Hello, Yungsang!</div>

        <div class="todo">주 3회 운동하기!</div>

    </div>

    <div class="quote">

        <div id="author" class="author">- 명언의 저자 -</div>

        <div id="content" class="content">" 명언의 내용 "</div>

    </div>

</body>


</html>






$(document).ready(function () {

    renderCurrentTime();

    renderQuote();

});



function renderCurrentTime() {

let url = `https://worldtimeapi.org/api/timezone/Asia/Seoul`;

fetch(url)

.then(res => res.json()).then((data) => {

    let datetime = data['datetime'].substr(11,5);

    $('#time').text(datetime);

});

}



function renderQuote() {

    let url = `https://api.quotable.io/random`;

    fetch(url)

        .then(res => res.json()).then((data) => {

            let content = `" ${data['content']} "`;

            let author = `- ${data['author']} -`;

            $('#content').text(content);

            $('#author').text(author);

        });

}


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴