DEV/javascript
Javascript 자식의 element를 참조하는 방법 (가져오는 방법)
석봉
2022. 10. 29. 14:58
작업을 하다보면 하위 자식 요소에 접근이 필요한 경우가 있다.
( 대표적으로 iframe을 사용하는 경우 )
다음과 같이 접근이 가능하다.
/**
* [자식 요소에 접근하는 방법]
* - 현재 document에서 하위 요소(id = "sampleEle")안에 있는 sampleEle2에 접근한다고 가정
*/
const sampleEle = document.getElementById("sampleEle");
const sampleEle2 = sampleEle.contentWindow.document.getElementById("sampleEle2");
반대로...?
https://seokbong.tistory.com/93
jQuery 부모의 element를 참조하는 방법 (가져오는 방법)
작업을 하다 보면 iframe을 쓰거나 부모의 element 요소를 참조하는 경우가 있다. 자식 페이지에서 부모의 element를 참조할 때는 다음과 같이 사용하자. 부모의 element의 값을(value) 가져오는 경우 $('#id
seokbong.tistory.com