HTML Code :
<div id="txtAge">
<table>
<tr>
<td><input type="checkbox" onclick="checking()" id="ch1" value="1"><td>
<td><input type="checkbox" onclick="checking()" id="ch2" value="10"><td>
<td><input type="checkbox" onclick="checking()" id="ch3" value="12"><td>
<td><input type="checkbox" onclick="checking()" id="ch4" value="3"><td>
</tr>
<tr>
<td><input type="checkbox" onclick="checking()" id="ch5" value="221"><td>
<td><input type="checkbox" onclick="checking()" id="ch6" value="130"><td>
<td><input type="checkbox" onclick="checking()" id="ch7" value="132"><td>
<td><input type="checkbox" onclick="checking()" id="ch8" value="3333"><td>
</tr>
</table>
</div>
Javascript :
function checking(){
$('input[type="checkbox"]').on('change', function() {
$(this).closest('tr').find('input').not(this).prop('checked', true);
alert(this.value);
});
}
This is my code. when i click the checkbox it alert one times, when i click other checkbox it alert 2 times.Why the onclick function trigger more than 1 time when i continue clicking the checkbox?
Here the demo:
onclick="checking()"from your HTML.