jQuery
.children() / .parent()
두루루루루
2017. 8. 16. 18:32
.children()
:Get the children of each element in the set of matched elements, optionally filtered by a selector.
* find() vs children()
find()는 선택된 요소의 하위 요소들을 모두 선택할 수 있지만, children()은 선택된 요소의 바로 아래 자식요소만 선택한다.
$('부모요소').children('선택할 요소');
https://jsfiddle.net/jywoo/3yd91ryn/1/
https://jsfiddle.net/jywoo/w6ev1bqq/1/
.parent()
:Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
각 요소들의 부모요소를 찾는 메소드
$('선택요소').parent();
https://jsfiddle.net/jywoo/ot78qm1u/
https://jsfiddle.net/jywoo/4zron44b/