본문 바로가기

STUDY/WEB

[jQuery] Attribute 속성

 
 

$('input[type="text"]');  - type 속성이 "text"인 input 엘리먼트

 

$('input[name="chooseOne"]');  - name 속성이 "chooseOne"인 input 엘리먼트

$('span[data-type="title"]'); -- data-type 속성을 지니며 그 값이 "title"인 모든 span 엘리먼트 

$('input[checked!="checked"]'); -- checked 속성의 값이 "checked"가 아닌 모든 input 엘리먼트 

$('p[id^="body"]');  -- id 속성값이 "body"로 시작되는 모든 p 엘리먼트 

( 예: id="bodyParagraph", id="bodySection" )

$('div[id$="Section"]'); -- id 속성값이 "Section"으로 끝나는 모든 div 엘리먼트 

( 예: id="headerSection", id="bannerSection" )

$('span[name|="tag"]');-- name 속성값이 "tag"와 일치하거나 "tag-"으로 시작되는 모든 span 엘리먼트 

( 예: name="tag", name="tag-pets", name="tag-fashion" )

$('a[href*="article"]'); -- href 속성값에 "article"이 포함된 모든 a 엘리먼트 

( 예: href="/articles/september", href="/entries/article" )

$('div[class~="buttonStyle"]'); -- class 속성값에 "buttonStyle"이 단어로 들어간 모든 div 엘리먼트

( 예: class="skinColor buttonStyle topDiv" )

$('div[data-pane]'); -- data-pane이라는 속성을 지닌 모든 div 엘리먼트

$('input[type="hidden"][data-value="userValue"]');

-- type 속성값이 "hidden"이고, 

-- data-value 속성값이 "userValue"인 모든 input 엘리먼트 선택