I am using jquery to select checkbox on and off when user click on image.
Here is my code:
function clickimage(e){
chkbox = e.parent().children('.chkBox');
if(chkbox.is(":checked")){
chkbox.attr('checked', false);
}else{
chkbox.attr('checked', true);
}
}
When I first click on image, the checkbox does checked. When I click on image again, the checkbox is unchecked. But the problem is after that, the checkbox will never be selected again.
I try to verify chkbox.is(":checked") and it does return false value. I put the checking code after chkbox.attr('checked', true);, it also return false value.
Why is it like that? How can I fix it?
Thank you.