checkbox .change works strange.
This code should alert just once a click.
But it multiplies the amount of clicks. Try clicking multiple times.
- <script type="text/javascript">
function mcheckbox(){
$("input").change(function() {
alert("checked");
});
}
</script></head><body>
<form>
<input type="checkbox" name="box3" id="mbox1" onclick="mcheckbox();">Checkbox1<br>
</form>
The next works well, but it fires on all clicks:
- <script type="text/javascript">
$(document).ready(function(){
$("input").change(function() {
alert("checked");
});
}
</script></head><body>
<form>
<input type="checkbox" name="box3" id="mbox1" >Checkbox1<br>
</form>
Is this a bug? How to solve by a onclick event?