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:

Navigate to another page using java script

06-03-2017 javascript redirection navigation

Filter for insert HTML in Angular Js

06-03-2017 filter show html angular js html

How to remove last / value from url in javascript

27-02-2017 array javascript last value

Call a function every second or 5 seconds in javascript

22-02-2017 setinterval function calling

Get random strings from given string In javascript

21-02-2017 javascript random string