General
Getting Started
Quick Install
Using with Cordova
Using with Vue.js
Mobiscroll CLI
ES6 Modules
Instance
Utility functions
Upgrade Guide v3
Date & Time pickers
Event Calendar
Form components
Alerts & Notifications
Buttons
Checkbox
Dropdown
Forms
Progress
Radio Buttons
Segmented
Slider
Stepper
Switch
Textfields
Timer
Responsive list
Numeric pickers
Pickers & dropdowns
Layout & navigation
Tools
Accessibility
Switch
Switches are bascially also checkboxes, but with a different style.
To make a switch, add the data-role="switch" attribute to a checkbox.
Wrapped in label element
<label>
I agree
<input id="agree" type="checkbox" data-role="switch"/>
</label>
Wrapped in div element
<div>
<label for="agree">I agree</label>
<input id="agree" type="checkbox" data-role="switch"/>
</div>
With description
<label>
I agree
<span class="mbsc-desc">Sample description</span>
<input id="agree" type="checkbox" data-role="switch"/>
</label>
For many more examples - simple and complex use-cases - check out the switch demos for javascript.
Options
Methods
| Name | Description | |
|---|---|---|
| getVal() |
Returns the state of the switch (true/false).
Returns: Boolean
ExampleMethods can be called on an instance. For more details see calling methods
|
|
| setVal(value) |
Sets the state of the switch (true/false).
Parameters
ExampleMethods can be called on an instance. For more details see calling methods
|
|