66
rated 0 times
[
70]
[
4]
/ answers: 1 / hits: 38994
/ 14 Years ago, wed, february 2, 2011, 12:00:00
I have two functions.
The first function translates a div click into a checked/unchecked toggle.
The second function translates a checkbox change into a hide/show event.
The problem is that when I use the first function to check/uncheck the box, the second function is not called. I am new to javascript, thanks.
<script type=text/javascript>
$(document).ready(function() {
$(:checkbox).parent().click(function(evt) {
if (evt.target.type !== 'checkbox') {
var $checkbox = $(:checkbox, this);
$checkbox.attr('checked', !$checkbox.attr('checked'));
evt.stopPropagation();
return false;
}
});
});
</script>
<script type=text/javascript>
$(document).ready(function() {
$(:checkbox).change(function() {
if($(this).attr(checked)) {
$('.'+this.id).show();
}
else {
$('.'+this.id).hide();
}
});
});
</script>
More From » jquery