This is My HTML Dom:
<input type="checkbox" class="chk-act" name="actionChk" value="17">
<input type="checkbox" class="chk-act" name="actionChk" value="18">
<input type="checkbox" class="chk-act" name="actionChk" value="19">
<input type="checkbox" class="chk-act" name="actionChk" value="20">
<input type="checkbox" class="chk-act" name="actionChk" value="21">
And I have a jQuery script that returned a JSon response by ajax:
["18","20","21"]
The list can be as long as up to 200 members. So I am interested to find out the fastest way to checked checkboxes, that have a value in above list, when the response is returned. What is your suggestion?
The fastest way would be to add an id identifier to your list of checkboxes. For example –
JS Perf Tests
Comparing the two current answers, the OP’s requirement of “fastest” would be better served by going down the uglier ‘id‘ implementation.
Js Perf
FIddle added
JS FIddle
Posting code from fiddle-