W3Schools.com

Document getElementsByName() Method

Document Object Reference Document Object

Definition and Usage

The getElementsByName() method accesses all elements with the specified name.

Syntax

document.getElementsByName(name)

Parameter Description
name Required. The name of the element you want to access/manipulate


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The getElementsByName() method is supported in all major browsers.


Example

Example

Alert the number of elements with a specific name:

<script type="text/javascript">

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

</script>

Try it yourself »


Document Object Reference Document Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE