728x90
반응형
속성 탐색 연산자
속성 탐색 연산자는 선택한 요소를 기준으로 일치하는 요소를 선택하는 선택자.
종류 | Jquery | Vanilla | 설명 |
(요소[속성]) | $("a[href]") | document.querySelector ("a[href]") |
a태그의 href값이 있는 요소를 가져옴 |
(요소[속성=값]) | $("a[title='element']") | document.querySelector ("a[title='element']") |
a태그의 title속성 값이 element인 요소를 가져옴 |
(요소[속성^=값]) | $("a[href^='http://']") | document.querySelector ("a[href^='http://']") |
a태그의 href속성 값이 http://로 시작하는 요소를 가져옴 |
(요소[속성$=값]) | $("a[href$='com']") | document.querySelector ("a[href$='com']") |
a태그의 href속성 값이 com로 끝나는 요소를 가져옴 |
(요소[속성*=값]) | $("a[href*='tistory]") | document.querySelector ("a[href*='tistory']") |
a태그의 href속성 값에 tistory가 포함된 요소를 가져옴 |
(:text) | $(:text) 응용) $('.클래스명:text') |
input태그의 type이 text인 요소를 가져옴 |
728x90
반응형
'IT > javascript' 카테고리의 다른 글
[javascript] input 정규식으로 숫자만 입력되도록 설정하기 (0) | 2023.07.13 |
---|---|
[javascript] 배열 객체 메소드 (0) | 2023.06.14 |
[Javascript] 알면 유용한 자바스크립트(템플릿 리터럴, NULL 병합 할당 연산자, optional chaining) (0) | 2023.06.04 |
[javascript] new date와 Intl API로 날짜 쉽게 구하기 (0) | 2023.05.30 |
[javascript] 카카오지도 API + geolocation API로 현재 위치의 주소 찾기 (0) | 2023.05.24 |