Menu



Manage

파일 목록
Study_Web > 이후/jquery/14-5.html Lines 33 | 995 바이트
다운로드

                        <!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>
</head>
<script>
    document.addEventListener('DOMContentLoaded', () => {
        // 문서 객체 생성하기
        const header = document.createElement('h')
        // 생성한 태그 조작하기
        header.textContent = '문서 객체 동적으로 생성하기';
        header.style.color = 'white';
        header.style.backgroundColor = 'black';
        header.sytle.fontSize = '25px';
        // h태그를 body 태그 아래에 추가하기
        document.body.appendChild(header)
        setTimeout(() => {
            const h1 = document.querySelector('h1');
            document.body.removeChild(h1);
        }, 3000);
    })
</script>

<body>
    <h1>제거 대상 문서 객체</h1>
    <hq>
</body>

</html>