<body>
    <h1>내부 컨텐츠 접근 함수</h1>
    <h3>html()</h3>
    <h2 class="test1">
        <b>오늘은 금요일 입니다.</b>
    </h2>
    <h2 class="test2">
    </h2>
    <script>
        //text()/ html()
            //text():  html요소를 배제하고 문자열만 저장하건, 가져오는 함수
            //html(): html요소를 태그로 올바르게 인식하는 함수
        var temp=$('.test1').html();//getter의 역활
        console.log(temp);
        $('.test2').html(temp);  //setter 의 역활
        $('.test2').css('color','blue');
    </script>
    <hr>
    <h3>text()</h3>
    <h1 id="test3">
        <a href="#">구글로 이동하기</a>
    </h1>
    <h1 id="test4">
    </h1>
    <script>
        $(function(){
            var temp=$('#test3').text();//getter의 역할
            console.log(temp);
            $('#test4').text(temp); //setter 의 역할
            //만약 HTML 코드를 문자열로 받는다면?
            $('#test4').text(str);
        })
    </script>
</body>


'JQUERY > 함수' 카테고리의 다른 글
| 요소추가. append, prepend, before, after (0) | 2022.08.28 | 
|---|---|
| 요소 추가...appendTo, prepentTo, insertBefore..Afert (0) | 2022.08.28 | 
| each(), addClass(), toggleCalss() (0) | 2022.08.28 | 
| each(), addClass(), toggleCalss() (0) | 2022.08.28 | 
| select option change (0) | 2022.08.28 |