JavaScript SwitchButton

Set the checked property of the jqxSwitchButton. Author: http://jqwidgets.com

by Daniel Benjamin

HTML

<script src=" http://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<div id="jqxSwitchButton"></div>
<br />
<div id="output"></div>

JavaScript

$('#jqxSwitchButton').jqxSwitchButton({
    height: 35,
    width: 80,
    theme: 'energyblue',
    checked: true
});

var state ;
$("#jqxSwitchButton").on('click', function () {
    switch($("#jqxSwitchButton").val())
    {
        case true:
            state = 'ON';
            break;
        case false:
            state = 'OFF';
            break;
    }
    $("#output").html(state);
});