Skip to content

Commit 38211b9

Browse files
committed
added new section for getting checked state
1 parent 5d9ae89 commit 38211b9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,20 @@ <h3 class="text-secondary mt-4">Methods</h3>
445445
</tbody>
446446
</table>
447447
</div>
448+
449+
<h3 class="text-secondary mt-4">Checked State</h3>
450+
<p>You can determine the checked state of a toggle using the `checked` property.</p>
451+
<div class="example">
452+
<input id="toggle-state" type="checkbox" data-toggle="toggle">
453+
</div>
454+
<div id="chkState" class="example">
455+
<button type="button" class="btn btn-outline-primary" onClick="showChkState()">Show Toggle State</button>
456+
</div>
457+
<p>
458+
<div>Use the element property for checked state</div>
459+
<code>document.getElementById('toggle-state').checked</code>
460+
<div>Returns true/false</div>
461+
</p>
448462
</section>
449463

450464
<section id="events" class="container my-5 d-none d-sm-none d-md-block">
@@ -542,6 +556,13 @@ <h4 class="font-weight-light">
542556
<script src="doc/script.js"></script>
543557
<script src="js/bootstrap4-toggle.js"></script>
544558
<!-- ^^^ scripts ^^^ -->
559+
<script>
560+
function showChkState() {
561+
$('#chkState .badge').remove();
562+
var chkBool = document.getElementById('toggle-state').checked;
563+
$('#chkState button').after('<div class="badge badge-success px-3 py-2 mb-2 mx-3">'+chkBool+'</div>');
564+
}
565+
</script>
545566
<!-- Global site tag (gtag.js) - Google Analytics -->
546567
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-75147115-4"></script>
547568
<script>

0 commit comments

Comments
 (0)