티스토리 뷰

728x90
<!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>
    <script src="/JS/jquery-3.6.0.min.js"></script>
    <style>

    </style>
</head>

<body>
    <h1><strong>객체 조작 및 생성</strong></h1>
    <section id="sec_1">
        <h2><em>html()</em></h2>
        <p>내용1</p>
    </section>

    <section id="sec_2">
        <h2><em>텍스트()</em></h2>
        <p>내용2</p>
    </section>

    <script>
            $(function(){
                // innerHTML : JQ식으로 작성
                let result_1 = $("#sec_1").html();
                console.log(result_1);

                $("#sec_1 p").html(`<a href=\"#\">Text1</a>`);

                // innerText : JQ식으로 작성
                let result_2 = $("#sec_2").text();
                console.log(result_2);

                $("#sec_2 h2").text("text()");
                
            });
    </script>
</body>

</html>

728x90
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
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
글 보관함