본문 바로가기

[IT/Programming]/HTML related

Getting html of container including the container itself

반응형
# Getting html of container including the container itself jQuery 를 이용하거나 그냥 JavaScript 를 이용해서 내부의 html 은 다음과 같이 끄집어낼 수 있다. ```[.lang-js] let containerHTML = $("#container").html(); let containerInnerHTML = $("#container")[0].innerHTML; ```/ ## PH
  • 2024-02-06 : First posting.
## TOC ## 예제 (innerHTML) 아래 html 은 다음과 같다. ```[.lang-html] <div id="container"> <div class="rC recoeve"><div class="rSC"> <iframe src="https://recoeve.net/user/kipid?cat=%5BMusic%2FBreak%5D--K-Pop#headPlay" frameborder="0"></iframe> </div></div> </div> ```/
다음과 같은 함수들로 내부 html 을 뽑아와 보자. ```[#pre-code-innerHTML.lang-html] ```/ ```[#pre-conHTML.lang-html] ```/ ```[#pre-conInnerHTML.lang-html] ```/ ## jQuery.wrap() .unwrap() and .outerHTML ```[#pre-code-outerHTML.lang-html] ```/ ```[#pre-conOuterHTML0.lang-html] ```/ ```[#pre-conOuterHTML.lang-html] ```/ ## RRA
  1. stackoverflow.com :: jQuery get html of container including the container itself, by Pinkie, at 2011-06-23
  2. stackoverflow.com :: In jQuery, are there any function that similar to html() or text() but return the whole content of matched component?, by jeffu, at 2009-06-15
반응형