I would like to catch a checkbox change and also catch the index of the checkbox selected or unselected. I'm wondering if this could be ok.
$("input[type='checkbox']").change(function () {
$("input[type='checkbox']").each(function (i) {
//my code here
switch (i) {
case 0:
break;
case 1:
break;
.
.
}
});
});
My html is something like this:
<table>
<tr>
<td id='led' bgcolor=#cccccc>OFF</td>
<td><input type='checkbox' name='' value='' ></td>
</tr>
<tr>
<td id='led' bgcolor=#cccccc>OFF</td>
<td><input type='checkbox' name='' value='' ></td>
</tr>
<tr>
<td id='led' bgcolor=#cccccc>OFF</td>
<td><input type='checkbox' name='' value='' ></td>
</tr>
<tr>
</table>
So I would like to detect what box was selected and then change the led to ON and to red background color. On the other hand if the the box is unselected I want to return the LED to OFF and change color to #cccccc