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 upload file by using request module

18-03-2017 request module node js

Using slice remove last two characters from given string

07-03-2017 slice remove

Navigate to another page using java script

06-03-2017 javascript redirection navigation

Filter for change Date format (MM-dd-yyyy) in Angular Js

05-03-2017 mm-dd-yyyy date formats angular js

How to get drop down value when drop down change using javascript

27-02-2017 onchange events dropdown javascript functions