I'd like to show an input (type = email), if the checkbox is checked. If its not checked, I'd like to hide it. My problem is, the input field is always visible.
jQuery:
$("#newsletterCheckbox").change(function () { if ($(this).is(":checked")) { $("#newsletterInputfield").show(); } else { $("#newsletterInputfield").hide(); } });
HTML:
<input name="checkboxNewsletter" type="checkbox" id="newsletterCheckbox" />Newsletter ... <div id="newsletterInputfield"> <input type="email" placeholder="Email*" id="email" class="inputFields" /> </div> I've tried This and a plenty of other examples. Thanks in advance.
changeevent, and no change has happened at page load. If you want it to load hidden, you should preferrably hide it with css.