jQuery radio button show div

前端 未结 4 709
余生分开走
余生分开走 2021-01-15 18:53

Hey guys, what function could I use to say, if this radio button is checked show this \'div\'. Thanks in advance.

4条回答
  •  走了就别回头了
    2021-01-15 19:48

    I liked @tinifni's jsfiddle. Here's one with 3 divs that show or hide depending on the radio.

    http://jsfiddle.net/dbwest/wmKGd/572/

    $('#form-id').change(function() {
        if ($('#watch-me').attr('checked')) {
            $('#show-me').show();
        } else {
            $('#show-me').hide();
        }
        if ($('#watch-me2').attr('checked')) {
            $('#show-me2').show();
        } else {
            $('#show-me2').hide();
        }
        if ($('#watch-me3').attr('checked')) {
            $('#show-me3').show();
        } else {
            $('#show-me3').hide();
        }
    });
    

提交回复
热议问题