उदाहरण
toggle() और this.checked से चेकबॉक्स स्टेट के आधार पर एलिमेंट दिखाएं/छिपाएं।
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="checkbox" id="selectName"/>
<div id="txtName" style="display:none">Your name is Adam Smith</div>
<script>
$('#selectName').click(function() {
$("#txtName").toggle(this.checked);
});
</script>
</body>
</html>
फ़ाइल सेव करें और Live Server से खोलें।
आउटपुट
चेकबॉक्स चेक करने पर डिव दिखाई देगा, अनचेक करने पर छिप जाएगा।