I have checkboxes created dynamically on the page after an ajax call.
Using a few posts in here I was able to attach event to the container div of the checkboxes and the event fires now.
HTML
<div class="AvailableProducts" id="AvailableProducts">
<ul><input type="checkbox" id="availableProduct" value="Apple" class="productsSelected"><span>Apple</span>
<br><input type="checkbox" id="availableProduct" value="Orange" class="productsSelected"><span>Orange</span> <br>
</ul>
</div>
And I’ve the event wired up like below
$(document).ready(function () {
$('#AvailableAdvertisers').live('change', 'input:checkbox', function () {
alert('Fired!');
});
});
Now I do not know how to get which checkbox was checked.
Thanks.
Edit:
Got it. I can do that with below code
$(this + ":checked").val()
$(this + ":checked + span").text()
1 Answer