속성값에 해당하는 단어를 찾을 때 사용하며 value값에 정확히 매칭되는 것만 찾는다.
단어에 공백이 들어가면 공백으로 구분된 단어와 일치할 때도 매칭된다.
value의 쌍따옴표는 필수다.

사용예
<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
</head>
<body>
  <input name="man-news" />

  <input name="milk man" />
  <input name="letterman2" />
  <input name="newmilk" />
<script>$('input[name~="man"]').val('mr. man is in it!');</script>

</body>
</html>
위 예제는 input 태그의 속성값으로 man 이라는 단어가 들어가 있는 것을 찾아 input 태그의 값을 부여한다.

'jQuery' 카테고리의 다른 글

Attribute Ends With Selector [name$="value"]  (0) 2010.12.30
Attribute Contains Selector [name*="value"]  (0) 2010.12.30
.innerHeight() .innerWidth()  (0) 2010.12.28
.addClass() .removeClass()  (0) 2010.12.28
.fadeIn() .fadeOut()  (0) 2010.12.28
Posted by IT

블로그 이미지
IT

공지사항

Yesterday
Today
Total

달력

 « |  » 2025.5
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

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함