"JQuery .replaceWith()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(사용자 2명의 중간 판 4개는 보이지 않습니다)
4번째 줄: 4번째 줄:
*대상 요소를 새 것으로 교체하는 함수
*대상 요소를 새 것으로 교체하는 함수


==참고 자료==
==예시==
<syntaxhighlight lang='html5'>
<script src="//code.jquery.com/jquery.min.js"></script>
<div class='container'>
  <p>한놈</p>
  <p>두시기</p>
  <p>석삼</p>
</div>
 
<script>
$('.container p:nth-child(2)').replaceWith('<p>너구리</p>');
</script>
</syntaxhighlight>
<jsfiddle styles='result' height='150'>2jz59ffq</jsfiddle>
 
==참고==
*http://api.jquery.com/replacewith/
*http://api.jquery.com/replacewith/
*http://www.w3schools.com/jquery/html_replacewith.asp


[[분류: jQuery Manipulation]]
[[분류: jQuery Manipulation]]

2020년 11월 2일 (월) 02:53 기준 최신판

1 개요[ | ]

jQuery replaceWith
jQuery .replaceWith()
  • 대상 요소를 새 것으로 교체하는 함수

2 예시[ | ]

<script src="//code.jquery.com/jquery.min.js"></script>
<div class='container'>
  <p>한놈</p>
  <p>두시기</p>
  <p>석삼</p>
</div>

<script>
$('.container p:nth-child(2)').replaceWith('<p>너구리</p>');
</script>

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}