How to use document.getElementByName and getElementByTag?

前端 未结 6 1748
一生所求
一生所求 2020-11-29 08:38
 document.getElementById(\'frmMain\').elements

can i use like this

document.getElementByName(\'frmMain\').elements 
6条回答
  •  醉梦人生
    2020-11-29 09:21

    I assume you are talking about getElementById() returning a reference to an element whilst the others return a node list. Just subscript the nodelist for the others, e.g. document.getElementBytag('table')[4].

    Also, elements is only a property of a form (HTMLFormElement), not a table such as in your example.

提交回复
热议问题