New to Kendo UI for jQuery? Start a free 30-day trial
Checked Switch
Updated over 6 months ago
The checked state of the Switch depends on the checked configuration option or the checked attribute of the widget element.
The following example demonstrates how to initialize the Switch from a checked input.
html
<input type="checkbox" id="switch" checked="checked" />
<script>
var switchInstance = $("#switch").kendoSwitch();
</script>
The following example demonstrates how to initialize a checked Switch by using the jQuery plugin syntax.
html
<input type="checkbox" id="switch" />
<script>
var switchInstance = $("#switch").kendoSwitch({
checked: true
});
</script>
The following example demonstrates how to get or set the Switch checked state.
html
<input id="switch" />
<script>
var switchInstance = $("#switch").kendoSwitch().data("kendoSwitch");
//get the Switch checked state
console.log("Is Swicth checked?: " + switchInstance.check());
//set the Switch checked state
switchInstance.check(true);
//get the Switch checked state
console.log("Is Swicth checked?: " + switchInstance.check());
</script>