Sometimes, we want to get name of form element with JavaScript.
In this article, we’ll look at how to get name of form element with JavaScript.
How to get name of form element with JavaScript?
To get name of form element with JavaScript, we use the getAttribute
method.
For instance, we write
const name = element.getAttribute("name");
to call element.getAttribute
with 'name'
to get the value of the name
attribute of the element
.
Conclusion
To get name of form element with JavaScript, we use the getAttribute
method.