例:
<form action="" name="lee"> <input type="text"></form>
通过getElementsByTagName:
var form = document.getElementsByTagName('form')[0]console.log(form)
通过item(n):
var form = document.forms.item(0)console.log(form)
通过namedItem(name):
var form = document.forms.namedItem('lee')console.log(form)
输出:
<form action="" name="lee"><input type="text"></form>
适用对象:
1、document.all2、document.anchors3、document.forms4、document.images5、document.links