How can I "get" the checkbox that changed inside div "containerDIV"?
View:
@model MyModel
<div id="containerDIV">
<ul id="CheckBoxList">
@foreach (XObject t in MyModel.XCollection)
{
<li>
<input type="checkbox" value="@t.id"/>
</li>
}
</ul>
On the JavaScript (Jquery) side, I have this:
$('#containerDIV').on('change', '#CheckBoxList', function (event) {
var id = $(this).val(); // this gives me null
if (id != null) {
//do other things
}
});
It's clear that $this is not the checkbox, it's the div containerDIV or checkBoxList
How can I get to the checkbox's state and value?
event.targetwould be the dom element which triggered the change event