HTML DOM getElementsByName()Method

Document 对象参考手册Document Object

Definition and Usage

The getElementsByName() method returns a collection of objects with the specified name.

Syntax

document.getElementsByName(name)

Parameter Description
name Required. The name of the element.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getElementsByName() method


Example

Example

Alert the number of elements with the specified name:

<script>

var x=document.getElementsByName("x");
alert(x.length);

</script>

Try it yourself »


Document 对象参考手册Document Object Other Extensions