How to get id by using name attribute in javascript

20-03-2017 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
Remove last two characters from given string
06-03-2017 substring javascript remove
How to find Angular Errors
06-03-2017 errors angularjs exceptionHandler
Email validation regular expression in javascript
22-02-2017 email validation regex
Send Mail in Node Js
21-02-2017 node js mail npm module