Reputation: 801
Within an .each(function(), I'm trying to uncheck checkboxes.
In line 1, I'm setting the value on 2 different Id's and this works fine.
What I want to do, is to unset both of the checkboxes on a single line. i.e take lines 3 & 4 and combine into 1 line. Line 2 is what I've tried, but it's not working (it doesn't do either of them).
(The 'wsSeq' is created by the server side, so that I get unique ID's on multiple rows).
$('#wsDocRef,#wsSupp').val('');
// $("'#wsTransferToQuarantine" + wsSeq + ",#wsTransferToSupplier" + wsSeq + "'").attr('checked', false);
$('#wsTransferToQuarantine' + wsSeq).attr('checked', false);
$('#wsTransferToSupplier' + wsSeq).attr('checked', false);
Upvotes: 1
Views: 107
Reputation: 237875
$("'#wsTransferToQuarantine" + wsSeq + ",#wsTransferToSupplier" + wsSeq + "'").attr('checked', false);
That isn't too far off, except for the unnecessary quotes. If wsSeq
is 1
, your selector looks like this:
$("'#wsTransferToQuarantine1,#wsTransferToSupplier1'").attr('checked', false);
Which is fine, except for the '
at each end. This should work fine:
$("#wsTransferToQuarantine" + wsSeq + ",#wsTransferToSupplier" + wsSeq).attr('checked', false);
With all that said, however, it may actually be quicker to do two ID selections than one multiple selection. This kind of optimisation is probably not necessary or a good use of your time.
Upvotes: 1
Reputation: 76880
Have you tried
$('#wsTransferToQuarantine' + wsSeq +',#wsTransferToSupplier' + wsSeq ).prop('checked', false);
You were just using two extra quotes in your call that are not needed
Upvotes: 0