chain이란?
jQuery의 메소드들은 반환값으로 자기 자신을 반환해야 한다는 규칙이 있다.
이를 이용하면 한번 선택한 대상에 대해 연속적 제어를 할 수 있다.
chain의 장점
1. 코드가 간결해진다.
2. 인간 언어와 유사해 사고의 자연스러운 과정과 일치
chain을 이용한 jQuery
See the Pen 1019_jQuery_chain by limhaneul2244 (@limhaneul2244) on CodePen.
탐색(traversing)
chain의 대상을 바꿔서 체인을 계속 연장시키는 방법
See the Pen 1019_jQuery_traversing by limhaneul2244 (@limhaneul2244) on CodePen.
https://api.jquery.com/category/traversing/
Traversing | jQuery API Documentation
Create a new jQuery object with elements added to the set of matched elements. Add the previous set of elements on the stack to the current set, optionally filtered by a selector. Add the previous set of elements on the stack to the current set. Get the ch
api.jquery.com
▼제이쿼리의 메소드들을 확인해볼 수 있다.
jQuery API Documentation
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. If you're new t
api.jquery.com
'Script > jQuery' 카테고리의 다른 글
[jQuery] scrollTop을 이용해 window 높이값을 구하기 (header 변경) (0) | 2021.10.27 |
---|---|
[jQuery] jQuery form요소 알아보기 (0) | 2021.10.19 |
[jQuery] slide Down 모달창 만들기 (feat. animate) (0) | 2021.10.17 |
[jQuery] form전송 시 공백유무에 따라 전송유무 달리하기(feat. if문) (0) | 2021.10.10 |
[jQuery] jQuery를 이용해 input의 특정 값을 가져오기 (0) | 2021.10.10 |