I have a really interesting problem. I am trying to uncheck all the checkboxes on my page. All flags have identifiers starting with "chkbx _".
I tried to do this:
$('input[id^="chkbx_"]').removeAttr("checked");
and this:
$('input[id^="chkbx_"]').attr("checked", false);
It works only once! The second time, it seems, it is ignored.
Basically, I'm trying to make checkboxes to behave like switches. When I check one, I run a function that receives this parameter (ref.) As a parameter, and first uncheck all the checkboxes, and then check the one that clicked.
I also tried using this to go through all the checkboxes to check if they are checked:
$('input[id^="chkbx_"]').each(function () { ... });
Despite the presence of 4 flags, the above loop runs only once, for the first flag on the page.
What's wrong? Thanks
source share