I have this jsfiddle, http://ift.tt/2raEqPN, that does what I want exactly, except for one thing: clicking the actual checkbox doesn't check it. I'm trying to make clicking the checkbox easier for users so instead of having to click the tiny checkbox they click the whole div and it'll check it AND add a a background-color. But people aren't always that smart so they'll still try to click the actual checkbox. Here's the js:
$('.AddCheckedWrapper').click(function () {
var checkbox = $(this).find('input[type=checkbox]');
checkbox.prop("checked", !checkbox.prop("checked"));
$(this).toggleClass('Checked');
});
I'm trying to alternate it so the clicking the checkbox checks is as well as clicking the div it's in.
I tried adding in
$(checkbox).click(checked);
But that did not work. I just need the checkbox to be checked if it's clicked, or if the div is clicked on while keeping the appropriate background color if it's checked or not. I appreciate any help!
Aucun commentaire:
Enregistrer un commentaire