Javascript Reference - HTML DOM Fieldset type Property








The read only type property returns which type of form element a fieldset is.

For a fieldset, this property will always return "fieldset".

Browser Support

type Yes Yes Yes Yes Yes

Syntax

var v = fieldsetObject.type 

Return Value

A string type value representing the type of form element the fieldset is.





Example

The following code shows how to get the form element type.


<!DOCTYPE html>
<html>
<body>
<form>
  <fieldset id="myFieldset">
    <legend>Information:</legend>
    Name: <input type="text"><br>
    Email: <input type="text"><br>
    Date of birth: <input type="text">
  </fieldset>
</form><!-- ww w.j a  va2 s. c o m-->
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myFieldset").type;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

The code above is rendered as follows: