I have a simple script that works only once. My script will check a checkbox if I click anywhere inside a table row. However, if I click inside the row a second, third, etc. time, then it doesn't work anymore. Why? I am now using jquery 1.9.1. My script worked previously when I was using jquery 1.8 with live()
instead of on()
.
HTML:
<tr class="row">
<td><input type="checkbox"></td>
</tr>
jquery:
$(document).ready(function(){
$("body").on("click",".row",function(){
var loc = $(this).find('input');
var ischecked = loc.attr("checked");
if(ischecked) {
loc.attr("checked", false);
} else {
loc.attr("checked", true);
}
});
});