티스토리 뷰


jQuery 기본 선택 방법 (선택자)

The selectors follow the basic format of CSS. You will be able to refer the formats in the site of CSS selectors too. It's also able to use the dependency for the parents of the element just like the CSS.

$('div') - selects all the elements that has the tags with <div>, 태그로 선택
$('.classSel') - selects all the elements that has the class 'classSel', 클래스로 선택
$('#idSel') - selects all the elements that has the id 'idSel', 아이디로 선택

Example)
$('div').text("changes all the <div> text to this")


<div> 의 모든 텍스트를 바꾸는 기능.
클래스/아이디로 선택하는 방법도 비슷하게 응용 가능하고 CSS에서 사용하는 하위 종속 선택도 가능하다.

$('div span') - will select the <span> elements inside another <div> element like below.

<div>
<span> Select this tag, 이 태그를 선택한다.
</span>
</div> 
위의 것만 잘 활용해도 충분히 거의 모든 상황에 대처가 가능하다. 자세한건 나중에 기회가 되면..!

More types of references are @ http://api.jquery.com/category/selectors/
 



공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
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
글 보관함