"JQuery input name으로 선택"의 두 판 사이의 차이

21번째 줄: 21번째 줄:
</form>
</form>
</source>
</source>
→버튼을 누르면 jmnote라는 이름을 가진 input text의 value인 apple이 출력된다.
*예제: http://jmnote.com/jq/by_name.php
*예제: http://jmnote.com/jq/by_name.php



2012년 3월 26일 (월) 21:00 판

  • jQuery 이름으로 찾기
  • jQuery 폼 요소 이름으로 선택

1 예제 소스

<!DOCTYPE html>
<meta charset='utf-8' />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#test").click(function() {
		alert($("input[name=jmnote]").attr("value"));
	});
});
</script>
<form name='my_form'>
<input type='text' name='jmnote' value='apple' />사과</label>
<input type='button' id='test' value='이름으로 찾기 테스트' />
<br/>
</form>

→버튼을 누르면 jmnote라는 이름을 가진 input text의 value인 apple이 출력된다.

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}