📝
jQuery
  • 제이쿼리
  • 제이쿼리 기본
  • 선택자
    • 기본선택자
    • 계층 선택자
    • 속성 선택자
    • 기본 필터 선택자
    • 내용 필터 선택자
    • 보임 필터 선택자
    • 자식 요소 필터 선택자
    • 폼 요소 선택자
  • 탐색
    • find()/fiter()
    • each()/$.each()
  • 속성
    • addClass()/removeClass()
    • toggleClass()
    • hasClass()
    • attr()/removeAttr()
    • position()/offset()
    • scrollTop()/scrollLeft()
  • 변경
    • remove()/empty()
    • append()/prepend()
    • text()/html()
  • 애니메이션
    • show()/hide()
    • fadeIn()/fadeOut()
    • slideUp()/slideDown()
    • animate()
  • 이벤트
Powered by GitBook
On this page

Was this helpful?

  1. 변경

text()/html()

html()메서드는 선택한 요소의 하위 요소를 가져와 문자열로 반환하거나 하위 요소를 전부 제거하고 새 요소로 바꿀 때 사용합니다. 그리고 text()메서드는 선택한 요소에 포함되어 있는 전체 텍스트를 가져오거나 선택한 하위 요소를 전부 제거하고 새 텍스트를 생성할 때 사용합니다.

$("선택자").text(); $("선택자").text("변경할 요소"); $("선택자").html(); $("선택자").html("변경할 요소");

$(".btn2").click(function(){
    $("li:eq(2)").text("text()메서드는 선택한 요소에 포함되어 있는 전체 텍스트를 가져오거나 선택한 하위 요소를 전부 제거하고 새 텍스트를 생성할 때 사용합니다.");
});

$(".btn3").click(function(){
    $("li:eq(1)").html("<strong>addClass()</strong>메서드는 선택한 요소에 클래스를 생성하고, removeClass() 메서드는 선택한 요소에서 지정한 클래스를 삭제합니다.")
});

$(".btn4").click(function(){
    $("li:eq(1)").text("<strong>addClass()</strong>메서드는 선택한 요소에 클래스를 생성하고, removeClass() 메서드는 선택한 요소에서 지정한 클래스를 삭제합니다.")
});
Previousappend()/prepend()Next애니메이션

Last updated 4 years ago

Was this helpful?