The Fieldset object represents an HTML <fieldset> element.
Property | Description |
---|---|
disabled | Sets or gets whether a fieldset is disabled |
form | Returns a reference to the form that contains the fieldset |
name | Sets or gets the name attribute of a fieldset |
type | Returns element type |
The Fieldset object supports the standard properties and events.
We can access a <fieldset> element by using getElementById().
<!DOCTYPE html>
<html>
<body>
<fieldset id="myFieldset" name="information">
Name: <input type="text" name="username"><br>
Email: <input type="text" name="usermail"><br>
</fieldset>
<button onclick="myFunction()">test</button>
<!--from w w w. j ava 2 s. c om-->
<script>
function myFunction() {
var x = document.getElementById("myFieldset");
x.disabled = true;
}
</script>
</body>
</html>
The code above is rendered as follows:
We can create a <fieldset> element by using the document.createElement() method.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from www . ja v a2 s .c o m-->
var x = document.createElement("FIELDSET");
var t = document.createTextNode("content here...");
x.appendChild(t);
document.body.appendChild(x);
}
</script>
</body>
</html>
The code above is rendered as follows: