Computer >> 컴퓨터 >  >> 프로그램 작성 >> JavaScript

JavaScript로 문서의 양식 수를 얻는 방법은 무엇입니까?


문서의 양식 수를 확인하려면 양식을 사용하세요. JavaScript에서 길이 속성이 있는 속성

예시

다음 코드를 실행하여 문서의 양식 수를 가져올 수 있습니다. −

<!DOCTYPE html>
<html>
   <body>
      <form>
         Name: <input type="text" name="my_name" value="Amit">
         Subject: <input type="text" name="my_subject" value="Java">
         <input type="submit" value="Submit">
      </form>
      <script>
         var val = document.forms.length;
         document.write("<br>Number of forms in the document: "+val);
      </script>
   </body>
</html>