I am loading a set of checkboxes into a div using jQuery and the load function. My code
$("#cb-list").load('www.someurl.com');
where www.someurl.com returns html for a set of flags, for example.
<input type="checkbox" value="sddfdsf" name="cb[]" id="a1" />
<input type="checkbox" value="sddfdsf" name="cb[]" id="b2" />
I want to view the checkboxes that were returned, and then check some of them based on the parameters (I want to do this on a page that loads the checkboxes, not the page being loaded).
How do I do this using jQuery? So, for example, I can have 3 flags with identifiers a1, b2, c3, and I would like to check b2 and c3. I usually did
$("#b2").attr("checked") = 'checked';
$("#c3").attr("checked") = 'checked';
But this does not work, and I assume that this is because the checkboxes are loaded from an external link.
thank
source
share