mercredi 11 juillet 2018

Unchecking a class of checkbox

So I have this JQuery that intends to uncheck a particular class of checkbox:

$('.{$id}_class').prop('checked', false);

And I have this checkbox as requested by someone who needed an MVE:

<input type="checkbox" id="whocares" name="doesntmatter" class="{$id}_class"> 

I fire this inside another checkbox's onchange, and it does nothing. The class of checkbox does not uncheck. No exceptions.

This is jquery 1.8.3, so I shouldn't need to use attr for this. I tried using

$('.{$id}_class').each(function() { ($this).prop('checked', false) }) 

but that threw errors that $this was undefined. The class selector most certainly is not undefined, since show() and hide() work just fine on it.

I tried researching mass selectors and doers, but nothing in my searches came up that allowed it to apply to a class. So how do I uncheck a class of checkbox?




Aucun commentaire:

Enregistrer un commentaire