JQuery input 개수 세기

by JM note

HTML

<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>