Easy Tutorial
❮ Event Ondragleave Jsref Push ❯

Checkbox defaultChecked Property


Definition and Usage

The defaultChecked property returns the default value of the checked attribute.

This property returns true if the checkbox is checked by default, otherwise it returns false.

Syntax


Browser Support

All major browsers support the defaultChecked property.


Example

The following example returns the value of the checked attribute:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function displayResult(){
    var x=document.getElementById("myCheck").defaultChecked;
    alert(x);
}
</script>
</head>
<body>

<form>
<input type="checkbox" id="myCheck" checked="checked">Do you like summer?
</form>
<button type="button" onclick="displayResult()">Is the default checkbox checked?</button>

</body> 
</html>

❮ Event Ondragleave Jsref Push ❯