Just a simple question.
I'm using
console.log(jQuery(event.target).is(":checked"));
and it returns false everytime.
If I do a console.log(jQuery(event.target)) is prints out the input box, so I know event.target is correct.
I can't use this here because the jQuery event is bound to a parent div.
Any ideas why this wouldn't work? Seems easy enough.
EDIT######################################### Rest of code:
jQuery(".core-create-install-pkg-parent").live("click", function(event){
var cls = jQuery(event.target).attr("type");
if(cls != "checkbox"){
    event.stopPropagation();
    jQuery(".core-create-install-pkg-child:first", this).toggle();
}else{
    console.log(event.target);
    if(jQuery(event.target).is(":checked")){
        console.log("it's checked");
        jQuery("input[type=checkbox]", this).removeAttr('checked'); 
    }else{
        console.log("not checked");
        jQuery("input[type=checkbox]", this).attr("checked", true);
    }
}
});
And the html looks like:
<div class="core-create-install-pkg-parent">
  <div class="core-create-install-pkg-title">
    <input type="checkbox" value="" checked>
    plugins
  </div>
</div>
                No need for jQuery:
event.target.checked
should work if event.target is a checkbox. But then, your code should work as well... if it does not, either the element is not a checkbox or something else is wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With