document.forms 예제
<form> site: <input type="text" name="site" value="홈짱닷컴"><br> host: <input type="text" name="host" value="Homzzang.com"> </form> <button onclick="homzzang()">클릭</button> <p id="demo"></p> <script> function homzzang() { var x = document.forms.length; document.getElementById("demo").innerHTML = x; } </script> 결과보기
<form>
site: <input type="text" name="site" value="홈짱닷컴"><br>
host: <input type="text" name="host" value="Homzzang.com">
</form>
<button onclick="homzzang()">클릭</button>
<p id="demo"></p>
<script>
function homzzang() {
var x = document.forms.length;
document.getElementById("demo").innerHTML = x;
}
</script>
결과보기
결과값: 1