Hide or show element if checkbox input is checked

Posted by & filed under Website Development.

For example, if you wish to hide or show a textbox based on if a checkbox is selected: HTML: <input id=”showTextbox” type=”checkbox” /> <textarea id=”textbox”></textarea> JS if($(“#showTextbox”).is(‘:checked’)) $(“#textbox”).show(); // checked else $(“#textbox”).hide(); // unchecked