Change the content of a div based on selection from dropdown menu

后端 未结 6 632
粉色の甜心
粉色の甜心 2020-11-30 00:14

Is there a simple way, using JavaScript, to dynamically show/hide content in a

based on the users selection from a drop down menu? For example, if a
6条回答
  •  孤城傲影
    2020-11-30 00:31

    Meh too slow. Here's my example anyway :)
    http://jsfiddle.net/cqDES/

    $(function() {
        $('select').change(function() {
            var val = $(this).val();
            if (val) {
                $('div:not(#div' + val + ')').slideUp();
                $('#div' + val).slideDown();
            } else {
                $('div').slideDown();
            }
        });
    });
    

提交回复
热议问题