0
<select id="sub-category" name="scat[]" multiple="multiple" placeholder="Select SubCategories"><option val=""></option>';

I have used select2 jquery plugin for selecting mutiple categories. Now i need to access values of multi-selected options using jquery like below. Can anyone help me.

tag1= $("#sub-category[0]").val();
tag2= $("#sub-category[1]").val();
tag3= $("#sub-category[2]").val();
tag4= $("#sub-category[3]").val();
  • welcome to stackoverflow, if you find any answer to resolving your problem, accept the answer by green mark on left side of answer – viral Jun 05 '15 at 12:25

1 Answers1

0

This will log the value of every selected option

$(function(){
    $('#some_button').click(function(){
        $('#sub-category :selected').each(function(){
            console.log($(this).val());
        });
    });
});
viral
  • 3,724
  • 1
  • 18
  • 32