$('#btnadd').click(addBulletinBoard);
function addBulletinBoard() {
var show = $('#show').val();
var show1;
console.log("before " + $('#show').val())
if (jQuery.inArray("*", show) !== -1) {
show1 = $("select#show option").map(function() {
return $(this).val();
}).get();
}
console.log("after :" + show)
console.log("after " + show1.splice(0, 2))
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="form-control" name="show" id="show" multiple="">
<option value="" selected="" disabled="">Select...</option>
<option value="*">All</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
</select>
<button type="button" class="btn btn-primary" id="btnadd">Submit</button>
I have a demo above. What I want to happened is when Selecting option from the select and the option ALL
is among the selected. I want to get all option except the first one and the second. So I used map with splice. But as seen in the console it is not what I am expecting.
How to get option values except first two in jquery