210403 JavaScript jQuery Text 연습

ITisIT210·2021년 4월 3일
0

jQuery

목록 보기
16/142
post-thumbnail
<!DOCTYPE html>
<html lang="en">
    <head>
            <meta charset="UTF-8">
            <title>Document</title>
            <style>
                div {
                    width: 200px;
                    height: 40px;
                    line-height: 40px;
                    padding: 10px;
                    background-color: #666;
                    color: lightblue;
                    margin: 30px auto;
                }
            </style>
    </head>
    <boby>
        <div class="box1">안녕하세요.</div>
        <div class="box2"></div>
        <div class="box3"><h3>반갑습니다.</h3></div>
        <div class="box4"></div>
        <div class="box5"></div>
        <script>
            // $(sel).text(); -> 해당 선택자의 텍스트 노드를 가져옴
            // $(sel).text(txt) -> 해당 선택지에게 특정 텍스트 노트를 추가

            var txt1 = $(".box1").text();
            $(".box2").text(txt1);

            // $(sel).html(); -> 해당 요소 안의 html 노드를 가져옴
            // $(sel).html(ele); -> 요소를 줄 수 있음

            var ele1 = $(".box3").html();
            $(".box4").html(ele1);
            $(".box5").html();
        </script>
    </boby>
    </html>
profile
Engineering is the closest thing to magic that exists in the world.

0개의 댓글