:text 는 input 중 type이 text 인 요소를 찾습니다.
원문 링크
http://api.jquery.com/text-selector/
- jQuery(':text')
예 제
텍스트 박스를 찾습니다.
<!DOCTYPE html>
<html>
<head>
<style>
textarea { height:25px; }
</style>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<form>
<input type="button" value="Input Button"/>
<input type="checkbox" />
<input type="file" />
<input type="hidden" />
<input type="image" />
<input type="password" />
<input type="radio" />
<input type="reset" />
<input type="submit" />
<input type="text" />
<select><option>Option</option></select>
<textarea></textarea>
<button>Button</button>
</form>
<div>
</div>
<script>
var input = $("form input:text").css({background:"yellow", border:"3px red solid"});
$("div").text("For this type jQuery found " + input.length + ".")
.css("color", "red");
$("form").submit(function () { return false; }); // so it won't submit
</script>
</body>
</html>
미리보기
$(':text') 선택자는 $('[type=text]') 로 대체하여 사용할 수 있습니다.
뭐 너무 평이해서 사족을 달게 없어요. ^^;;
그럼 즐프하세요.
※ 본 예제는 http://www.jquery.com 에 있는 내용임을 밝힙니다.
'프로그래밍 > jQuery' 카테고리의 다른 글
| jQuery API 정복 - 클래스가 있나 찾기, hasClass() (5) | 2011.03.03 |
|---|---|
| jQuery API 정복 - attr(), 속성을 제어하기 (2) | 2011.02.25 |
| jQuery API 정복 - addClass(), 클래스 추가하기 (5) | 2011.02.25 |
| jQuery API 정복 - 눈에 보이는 요소 찾기 : visible (5) | 2011.02.24 |
| jQuery API 정복 - submit 버튼 찾기 : submit (4) | 2011.02.22 |
| jQuery API 정복 - select 박스에서 선택된 것 찾기 : selected (4) | 2011.02.22 |
| jQuery API 정복 - reset 버튼 찾기 : reset (2) | 2011.02.21 |
| jQuery API 정복 - radio 버튼 찾기 : radio (2) | 2011.02.21 |