开发者

JS Show field when checked

开发者 https://www.devze.com 2022-12-20 03:57 出处:网络
How do i show an input field if #tryout checkbox is chec开发者_运维技巧ked. I already have this which hides 2 fields, now i want to show 3 new fields..:

How do i show an input field if #tryout checkbox is chec开发者_运维技巧ked.

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'));
});


Chain your selectors in this case:

$('#tryout').click(function () {
    $('#title, .navn').toggle(!$(this).attr('checked'));
    $('#newfield1, #nf2, #nf3').toggle($(this).attr('checked'));
});
0

精彩评论

暂无评论...
验证码 换一张
取 消