0

I am using the Bootstrap Switcher (https://bttstrp.github.io/bootstrap-switch/examples.html)

<p><input  type="checkbox" checked="checked" data-on-color="info" ></p>

<script src="js/jquery-3.3.1.js"></script>
<script src="js/highlight.js"></script>
<script src="https://unpkg.com/bootstrap-switch"></script>
<script src="js/main_switch.js"></script>

By default it looks like this:

enter image description here

But I would like the switcher to be default switched to ON:

enter image description here

But even if I set it to checked, it is always OFF. I also tried:

<p><input  type="checkbox" data-on-color="info" checked></p>

But no change.

I also tried:

<p><input  type="checkbox" data-on-color="info" checked="true"></p>

but no change

peace_love
  • 6,229
  • 11
  • 69
  • 157
  • According to the docs and online demo, the checked attribute is all that's necessary, so please provide a [mcve] demonstrating the issue. Also, the docs say any buttons need `data-toggle="switch"` – j08691 Aug 05 '20 at 15:52
  • Looks like you need to use a radio: https://getbootstrap.com/docs/4.2/components/forms/#switches – Pete Aug 05 '20 at 15:57

1 Answers1

2

use: data-toggle="switch"

code: <input type="checkbox" data-toggle="switch" checked>

test: https://jsfiddle.net/u38tq2r9/

dm4web
  • 4,642
  • 1
  • 14
  • 20