Web & Mobile/jQuery
[jQuery] find(), children() 차이
byunghyun23
2020. 8. 9. 23:48
1. $('selector').find()
-
해당 요소의 모든 하위 요소 중 특정 요소를 선택하여 가져옴
- $('#main').find('#content')
= #main의 자식 요소 중 #content 요소를 가져옴
2. $('selector').children()
-
해당 요소의 바로 아래 단계 자식 요소를 가져옴
- $('#main').children('#content')
= #main의 바로 아래 단계 자식 중 #content 요소를 가져옴 - $('#main').children(x)
= #main의 바로 아래 단계 자식 중 (x+1)번째 요소를 가져옴