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:

Example for Conditional Operator in php

16-04-2017 php Conditional Operator example

How to use request module in node js

16-03-2017 request module node js

How to use http-post request in node js

14-03-2017 http-post module node js

Sanitization in java sript

14-03-2017 sanitization java script

Sample Validations in javascript

22-02-2017 validations javascript