본문 바로가기
728x90
300x250
SMALL

javaScript/jQuery153

[jQuery]첫 번째 자식 요소 선택하기 첫 번째 자식 요소 찾기 $(선택자).children().first() $(선택자).children().eq(0) $(선택자).children(":first") $(선택자).children(":eq(0)") ul.list 자식 노드 중 첫 번째 자식 노드 border 변경 html A B C D :first 선택자 이용 var $list = $("ul.list"); $list.children(":first").css("border","3px solid #f00"); first() 메서드 이용방법 var $list = $("ul.list"); $list.children().first().css("border","3px solid #f00"); 결과는 같음 그렇다면 2개 중 좀 더 효율적인 방법은? 상황에 .. 2023. 1. 12.
[jQuery]children() find() 차이 바로아래 자식, 모든 자손 노드 children() find() 차이 children()메서드는 바로아래 자식 노드에서만 찾는다. find()메서드는 바로 아래 자식 노드 뿐만 아니고 모든 자손 노드에서 찾는다. children() 바로아래 자식 노드 선택 I II A B 1 2 3 C III 실행결과 find() 모든 자손 노드 선택 I II A B 1 2 3 C III 실행결과 2023. 1. 11.
[jQuery]contents() 주석 노드 포함 모든 직계 자식 반환 contents() 선택한 요소의 텍스트 및 주석 노드 포함 모든 직계자식을 반환 동일한 도메인에 있는 경우 iframe의 HTML에도 액세스할 수 있다. $(선택자).contents(); Hello world! What a beautiful day! In this example, by clicking on the button, we search for all the text nodes inside the div element and wrap them with a b element. div 요소 내부의 em 노드를 찾아 래핑 참고 : https://www.w3schools.com/jquery/traversing_contents.asp 2023. 1. 10.
[jQuery] 자식노드 찾기 children() 자식 노드란? 자식 노드는 특정 노드 바로 아래 위치한 노드를 말한다. 모든 자식 노드 찾기 $대상.children() I II A B 1 2 3 C III 실행결과 특정 자식 노드만 찾기 $대상.children("선택자") I II A B 1 2 3 C III 실행결과 참고 : https://api.jquery.com/children/#children-selector 2023. 1. 9.
728x90
반응형
LIST