I have an input type checkbox that is configured for on/off purposes, with values true/false accordingly. I want to be able to turn it off and on whenever i call a function using javascript.
The checkbox looks like this:
<div class="onoffswitch">
<input type="hidden" id="i" value="{{bc}}"/>
<input type="checkbox" data-type="bc-s" name="onoffswitch{{itemID}}-age" class="onoffswitch-checkbox bc-manage" id="asd" {{#bc}}checked{{/bc}} />
<label id="sbc" class="onoffswitch-label" for="myonoffswitch{{itemID}}-age">
<div class="onoffswitch-inner"></div>
<div class="onoffswitch-switch"></div>
</label>
</div>
I want to turn it on/off using this:
container.find("#asd").prop('checked', !data.bc);
but failed then tried this:
container.find("#asd").val(!data.bc);
and nothing works. I don't know why.
Aucun commentaire:
Enregistrer un commentaire