Change the "checked" property of the check box using jQuery and bootstrap (AdminLTE theme)

advertisements

I'm using the AdminLTE theme (which implements bootstrap) and I have a checkbox on my page. It gets rendered as follows -

<div class="icheckbox_minimal" style="position: relative;" aria-checked="false" aria-disabled="false">
<input id="subscribeAddress" type="checkbox" style="position: absolute; opacity: 0;">
<ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: none repeat scroll 0% 0% rgb(255, 255, 255); border: 0px none; opacity: 0;"></ins>
</div>

(note how a sprite is used to display the checkbox, while the actual input element is given an opacity of 0)

I now wish to change the checked property of the checkbox with jQuery. How would I go about doing this? I have tried the following without any luck -

$("#subscribeAddress").prop("checked", true);

$(".icheckbox_minimal").prop("aria-checked", true);

Update: I have found a solution to my question and posted an answer below, but am still open to suggestions on better approaches.


try below code

$("#subscribeAddress").iCheck('uncheck');