0

I am trying to change the status of toggle switch using jquery but not success. this is the code of jquery

$('#bandwidthcap').checked='false';

and I tried using this way

$('#bandwidthcap').attr('checked','false')

this is the code of html

<input type="checkbox"  name="bandwidthcap" id="bandwidthcap" class="switchery" data-color="primary"/>
empiric
  • 7,825
  • 7
  • 37
  • 48
ahmad blat
  • 41
  • 1
  • 1
  • 4

1 Answers1

0

You can use the .prop() function:

$('#bandwidthcap').prop("checked", true)
<input type="checkbox" name="bandwidthcap" id="bandwidthcap" class="switchery" data-color="primary" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Kobe
  • 6,226
  • 1
  • 14
  • 35