Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Openlayers
- Let
- VAR
- createtextnode
- const
- input
- 학습법 #집중력
- appendChild
- htmlFor
- createElement
- Append
- boolean
- FOR
Archives
- Today
- Total
Atomic Habits
[jQuery] $( "span", this ) Selector 본문
Selector Context
By default, selectors perform their searches within the DOM starting at the document root. However, an alternate context can be given for the search by using the optional second parameter to the $() function. For example, to do a search within an event handler, the search can be restricted like so:
$( "div.foo" ).click(function() {
$( "span", this ).addClass( "bar" );
});
When the search for the span selector is restricted to the context of this, only spans within the clicked element will get the additional class.
Internally, selector context is implemented with the .find() method, so $( "span", this ) is equivalent to $( this ).find( "span" ).
'IT > JavaScript-JQuery' 카테고리의 다른 글
동기식 (Synchronous) / 비동기식 (Asynchronous) (0) | 2022.07.07 |
---|---|
jQuery: data() 이해와 활용 (0) | 2022.07.06 |
세계협정시 UTC (0) | 2022.07.01 |
개발자도구 활용법(간단하지만 유용한 기능) (0) | 2022.07.01 |
[jQuery] 요소의 조작 - 요소의 추가 .append() .prepend() .before() .after() (0) | 2022.06.29 |
Comments