Jquery checking checkbox on click doesn't check it -
okay i'm using supersimple code check checkboxes. have invisible ahref on elements , checkbox next them. here's html:
<a href="#" class="transparent-checkbox-thingy" id="<?php echo $id;?>" onclick="check(<?php echo $id;?>)"></a> <input type="checkbox" value="<?php echo $id;?>" name="users[]" class="newconvo-check" id="<?php echo $id;?>">
so i've tried using method, check()
function , input tags have same id, using following jq:
function check(id) { var newid = '#'+id; $(newid).prop('checked', true); };
or 1
function check(id) { $('#' + id).prop('checked', true); };
or one
function check(id) { $(id).prop('checked', true); };
none of them work. return valid info on alert(id)
or alert(newid)
don't check damned checkbox. tried one:
$(document).ready(function() { $("a.transparent-checkbox-thingy").click(function(event) { event.preventdefault(); var thisid = ('#' + event.target.id); $(thisid).prop('checked', true); }); });
didn't work. tried this
$(document).ready(function() { $("a.transparent-checkbox-thingy").click(function(event) { event.preventdefault(); $('#1').prop('checked', true); }); });
didn't work. yes, there <input type="checkbox">
id="1"
always. , that's 1 i'm testing. , yes, have
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
you have used same id in <a>
, <input type="checkbox"
, id unique cant able use multiple place
<a href="#" class="transparent-checkbox-thingy" id="<?php echo $id;?>" onclick="check(<?php echo $id;?>)"></a> <input type="checkbox" value="<?php echo $id;?>" name="users[]" class="newconvo-check" id="<?php echo $id;?>">
use this,
<a href="#" class="transparent-checkbox-thingy" id="<?php echo $id;?>" onclick="check(<?php echo $id;?>)">check</a> <input type="checkbox" value="<?php echo $id;?>" name="users[]" class="newconvo-check" id="c_<?php echo $id;?>"> <script type="text/javascript"> function check(id) { var newid = '#c_'+id; $(newid).prop('checked', true); }; </script>
Comments
Post a Comment