자바스크립트 input 개수 세기

by JM note

HTML

<form name='my_form'>
  <input type='button' onclick='count_input();' 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>
  function count_input() {
    alert(my_form.tag.length);
  }
</script>