How to get id by using name attribute in javascript

20-03-2017 html id name javascript

I want to get id of my element by using name attribute, but there is an simple method in javascript. Here is the HTML 

<input type="text" name="name" id="id">

In javacript,

var ele = document.getElementsByName( 'name' );
var id = ele[0].getAttribute( 'id' );


You might also like:

How to use request module in node js
16-03-2017 request module node js
How to use http-post request in node js
14-03-2017 http-post module node js
Filter for change Date format (MM-dd-yyyy HH:mm) in Angular Js
05-03-2017 mm-dd-yyyy HH:MM date formats angular js
How to remove last / value from url in javascript
27-02-2017 array javascript last value
Email validation regular expression in javascript
22-02-2017 email validation regex