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

잔글 (121.133.101.143(토론)의 편집을 Jmnote의 마지막 판으로 되돌림)
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
4번째 줄: 4번째 줄:
; jQuery - input 배열 수 세기
; jQuery - input 배열 수 세기


<source lang='html'>
<syntaxhighlight lang='html'>
<form name='my_form'>
<form name='my_form'>
   <input type='button' id='my_button' value='개수 세기' />
   <input type='button' id='my_button' value='개수 세기' />
21번째 줄: 21번째 줄:
   });
   });
</script>
</script>
</source>
</syntaxhighlight>
<jsfiddle height='150'>8byz83bw</jsfiddle>
<jsfiddle height='150'>8byz83bw</jsfiddle>
:→ [개수 세기] 버튼을 누르면 tag[]의 개수 5가 출력된다.
:→ [개수 세기] 버튼을 누르면 tag[]의 개수 5가 출력된다.

2020년 11월 2일 (월) 02:53 기준 최신판

1 개요[ | ]

jQuery - HTML 요소 개수
jQuery - input text 개수 확인
jQuery - input 배열 수 세기
<form name='my_form'>
  <input type='button' id='my_button' value='개수 세기' />
  <hr>
  <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' />
</form>

<script src="//code.jquery.com/jquery.min.js"></script>
<script>
  $("#my_button").click(function() {
    alert($("input[name=tag]").length);
  });
</script>
→ [개수 세기] 버튼을 누르면 tag[]의 개수 5가 출력된다.

2 같이 보기[ | ]

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