File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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 >
You can’t perform that action at this time.
0 commit comments