I’m trying jQuery from scratch & I want to produce an effect when a checkbox button was checked, with jQuery. But I’m not having the effect I want.
<div>
<input type="checkbox" id="cb">
<label for="cb">Show Button</label>
</div>
<button id="but">
Button
</button>
$(() => {
$("#but").hide();
$("#cb").on("change", () => {
if($(this).is(":checked")) {
$("#but").show();
}
});
});
I realized it is not entering to the if block. I guess checked
prop should be called on a different way? How can I make this work?