How to get id by using name attribute in javascript

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 make an http request in node js

14-03-2017 http module node js

Get next date from given date in javascript

06-03-2017 date javascript next date

How to find Angular Errors

06-03-2017 errors angularjs exceptionHandler

Filter for replace text in Angular Js

05-03-2017 filter replace angular js

Call a function every second or 5 seconds in javascript

22-02-2017 setinterval function calling