I’d like to target a specific checkbox such as the ‘is-wine’ below but am not sure the syntax and ideally if it can be done in a single line.
Any ideas on how to do this? Basically just want to select the ‘is-wine’ checkbox and not the others.
thx
$(document).ready(function(){
$('.click-me').on('click',function(){
// doesn't work
//$('.chex input .is-wine').attr('checked',status);
$('.chex input').each( function() {
$(this).attr('checked',status);
});
});
});
</script>
</head>
<body>
here i am withing sub
<div id='my-killer-id'>
<div class='click-me'>clicke me for is-wine</div>
<div class='chex'>
<input type='checkbox' class='is-wine' /><br />
<input type='checkbox' class='is-coffee' /><br />
<input type='checkbox' class='is-tea' /><br />
<input type='checkbox' class='is-cocktail' /><br />
</div>
</div>
This should be without the space..
If you place a space there it will go to the child of the input (which has no children)
Check this FIDDLE
You can come up with multiple selectors for this .. As the class is unique