multiple select element - onchange

后端 未结 9 1986
栀梦
栀梦 2021-02-18 22:50

I have a select element that allows for multiple selections. I\'d like to display the selected values in another part of the page (in a div or something) as the user makes chang

9条回答
  •  天涯浪人
    2021-02-18 23:06

    In your fiddle, I just used .val(). This returns an array

    JSFiddle Link

    $(function() {
        $('#fruits').change(function() {
            console.log($(this).val());
        }); 
    });
    

提交回复
热议问题