커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
JS 연동이 안되는 것 같아요.
undefined주차
북마크
김*진
댓글
10
추천
0
조회수
32
조회수
32
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


시간과 명언 변경이 안돼요ㅜ, 기존 강사님이 강의자료로 주신 코드를 복붙해도 적용이 안되서 문의드립니다.

HTML, JS 코드 첨부드립니다!



스파르타 즉문즉답





작성한 코드 및 에러 메세지

<!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">


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/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://mblogthumb-phinf.pstatic.net/MjAyMjA0MDJfOTkg/MDAxNjQ4ODY3NDY2NzM5.kk-V1kAFf9u2wgWXJFMm3FEitywLrjHkVsm5cboplNMg.JbvdwgeNm-pUJXSH5yEP-UoIT2ppfd7vupjv1Cmwjxog.PNG.yurang43/%EC%95%84%EC%9D%B4%ED%8C%A8%EB%93%9C%ED%8F%AC%EC%8A%A4%ED%8C%852.png?type=w800");

            background-position: center;

            background-size: cover;


            color: white;

        }


        #time {

            font-size: 80px;

            font-weight: bold;

        }


        .greeting {

            font-size: 50px;

        }


        .todo {

            font-size: 30px;

        }


        #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
댓글 알림
나의얼굴