I have a function that runs when a checkbox is changed (works fine):
// event management
$("input.box[type=checkbox]").change(function() {
var name = $(this).attr("name");
$("input:checkbox[name='$name']").attr("checked", true);
$.cookie(name, $(this).prop('checked'), {
path: '/',
expires: 365
});
});
<input id="<?php echo the_ID();?>" type="checkbox" name="<?php echo the_ID();?>">
I also want to be able to change the state of the checkbox from another button:
<a onclick="$('#<?php echo the_ID();?>').attr('checked', true);">test</a>
This does change the checkbox but does not run the change function.
Any ideas? Thanks
Aucun commentaire:
Enregistrer un commentaire