Thursday, 15 January 2015

javascript - Get id from multiple checkbox when clicked -



javascript - Get id from multiple checkbox when clicked -

i want current id on click.and checked 1 checkbox. here input boxes

<table style="width: 500px; border: 1px solid black;"> <?php for($i=1; $i<10; $i++){ ?> <tr><td><input type="checkbox" name="mycheckboxes[]" class="chktag" id="chkbox<?php echo $i; ?>" /></td> <td><input type="checkbox" name="mytagcheckboxes[]" class="chktag" id="chkbox<?php echo $i; ?>" value=""/></td> <td><?php echo $i;?></td></tr> <?php }?> </table>

here jquery

$(document).ready(function(e){ $('input#chkbox1').on('change', function() { $('input#chkbox1').not(this).prop('checked', false); }); });

its work first one. didn't other id on click.

$(document).ready(function(e){ $('input').on('click', function(e){ var id = e.target.id; $('input#'+id).on('change', function() { $('input#'+id).not(this).prop('checked', false); }); }); });

fiddle here http://jsfiddle.net/spydo9s3/

javascript jquery

No comments:

Post a Comment