Monday, 20 February 2017

Get list of selected values in a ListBox


Below is the jquery function to get selected values in ListBox by iterating loop

$('#btn').click(function(){  
   var arr = [];
   $('.selectpicker :selected').each(function(i, selected){
        arr[i] = $(selected).text();
    });
    alert(arr);
});


If you want retrieve single selected value from list box use below code
$('.selectpicker').val();

No comments:

Post a Comment