Bootstrap Toggle (Switch button)
Applying change() on Bootstrap Toggle button
by Shankar
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://gitcdn.github.io/bootstrap-toggle/2.2.0/css/bootstrap-toggle.min.css">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.0/js/bootstrap-toggle.min.js"></script>
<input type="checkbox" checked data-toggle="toggle">
JavaScript
/*use change() on element with class 'toggle' rather than that with id "mapToggle" because bootstrap-toggle works like Shadow elements and in this case "mapToggle" will become a descendent of an element with class "toggle" which changes its bootstrap button class on switching from ON to OFF
This example still needs a workaround if there are more than one Bootstrap-Toggles on one page*/