w3c document.forms[0].fieldname equivalent

前端 未结 5 790
眼角桃花
眼角桃花 2021-01-14 03:35

I\'ve been using

document.forms[0].fieldname.value

to get values in javascript from a form, but I\'d like to use a name to reference the f

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-14 04:07

    The forms collection is standard DOM 1, there is nothing wrong with using it.

    document.forms.formId.elements.field
    

提交回复
热议问题