How to programmatically click checkbox with jQuery? I want to make a hidden checkbox which is checked when user clicks particular element, but my code doesn't work and I have no idea why.
Here's what I tried JSFiddle
code:
//HTML
<input type='checkbox'>
<a href='#' class='click_me'>click me</a>
//js
$('.click_me').click(function(){
console.log('click');
$(this).closest('input[type="checkbox"]').toggle();
})