hi guys, I got a checkbox and when the chebox is checked I want to show a div and when is unchecked I want to hide a div, but the code that I write isn't working:
$('#form').hide();
$('.chk').on('click', function () {
if ($(this).is(':checked'))
$('#form').show();
hi guys, I got a checkbox and when the chebox is checked I want to show a div and when is unchecked I want to hide a div, but the code that I write isn't working:
else
$('#form').hide(); });
Here's some code that will do the job but you should change the selectors I've used
http://codepen.io/karlpcrowley/pen/FHgct
Sorry, @karlpcrowley, two in a row makes it look like I'm a dick! Minor tweak since
live()is deprecated:http://codepen.io/ggilmore/pen/teFny
karlpcrowley and TheDoc thaks, more simple then my code
@TheDoc You're definitely not a dick, it's the reason we're here :)