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 submit form using javascript or jquery.
16-04-2017 javascript jquery submit form
How to upload file by using request module
18-03-2017 request module node js
How to convert html to pdf in Node js
12-03-2017 pdf convert html node js
Sample Validations in javascript
22-02-2017 validations javascript
Send Mail in Node Js
21-02-2017 node js mail npm module