Return the value of the name attribute of a fieldset:
var x = document.getElementById("myFieldset").name;
Click the button to display the name of the fieldset.
<!DOCTYPE html> <html> <body> <form> <fieldset id="myFieldset" name="MyNameFieldset"> Name: <input type="text" name="username"><br> Email: <input type="text" name="usermail"><br> </fieldset> </form>// ww w.j a v a 2 s. c om <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myFieldset").name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The name
property sets or gets the value of the name attribute of a fieldset.
The name attribute specifies the name of the fieldset field.
the name is used to reference form-data after it has been submitted to the server.
Only form elements with a name attribute will be submitted.
The name
property accepts and returns a String value.
Value | Description |
---|---|
name | Specifies the name of the fieldset |
The name
property returns a String representing the name of the fieldset.