How to use document.getElementByName and getElementByTag?

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

can i use like this

document.getElementByName(\'frmMain\').elements 
6条回答
  •  时光说笑
    2020-11-29 09:23

    1. The getElementsByName() method accesses all elements with the specified name. this method returns collection of elements that is an array.
    2. The getElementsByTagName() method accesses all elements with the specified tagname. this method returns collection of elements that is an array.
    3. Accesses the first element with the specified id. this method returns only a single element.

    eg:

    
    
    
        

    This will return a single HTML element and display the value attribute of it.

    
    
    
        

    this will return an array of HTML elements and number of elements that match the name attribute.

    Extracted from w3schools.

提交回复
热议问题