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:

Detect AdBlock with JavaScript in my browser

30-07-2017 AdBlock javascript detect

How to make an http request in node js

14-03-2017 http module node js

Convert Time 24 hrs to 12 hrs format In javascript

12-03-2017 date javascript 12hrs convert

Filters for convert text to camel case in Angular Js

05-03-2017 angularjs camelcase filters

Send Mail in Node Js

21-02-2017 node js mail npm module