views:

39

answers:

1

Hello. How do i show an input field if #tryout checkbox is checked.

I already have this which hides 2 fields, now i want to show 3 new fields..:

$('#tryout').click(function () {
    $('#title').toggle(!$(this).attr('checked'));
    $('.navn').toggle(!$(this).attr('checked'));
});
+1  A: 

Chain your selectors in this case:

$('#tryout').click(function () {
    $('#title, .navn').toggle(!$(this).attr('checked'));
    $('#newfield1, #nf2, #nf3').toggle($(this).attr('checked'));
});
Nick Craver
hmm, it works, but it still shows from the beginning. Should i set the input type to hidden?
Karem
@Azzyh - Whatever you don't want show from the start, use `style="display: none;"` on.
Nick Craver