"JQuery input 개수 세기"의 두 판 사이의 차이

12번째 줄: 12번째 줄:
$(document).ready(function(){
$(document).ready(function(){
$("#my_button").click(function() {
$("#my_button").click(function() {
alert($("input[type=text]").length);
alert($("input[name=tag]").length);
});
});
});
});
18번째 줄: 18번째 줄:
<form name='my_form'>
<form name='my_form'>
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='button' name='tag' />
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='hidden' name='tag' />
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='button' id='my_button' value='개수 세기' />
<input type='button' id='my_button' value='개수 세기' />

2016년 5월 13일 (금) 10:59 판

jQuery - HTML 요소 개수
jQuery - input text 개수 확인
jQuery - input 배열 수 세기

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(){
	$("#my_button").click(function() {
		alert($("input[name=tag]").length);
	});
});
</script>
<form name='my_form'>
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='text' name='tag' />
<input type='button' id='my_button' value='개수 세기' />
</form>

2 같이 보기

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