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 get current date and time (yyyy-mm-dd H:i:s) using javascript

09-03-2017 javascript date time

Get next date from given date in javascript

06-03-2017 date javascript next date

Navigate to another page using java script

06-03-2017 javascript redirection navigation

How to set or update or push the values into Object in javacript

27-02-2017 javascript set update push object

How to remove last / value from url in javascript

27-02-2017 array javascript last value