Reputation: 4008
I have this string:
var product = "bj,tg,ap,nl";
Now I´d like jQuery to select these values in a select2
option list. I know how to select just one:
$('#product').val('bj').trigger('change.select2');`
But how do i select all the comma separated values from that string? I guess it should look like:
$('#product').val('bj', 'tg', 'ap').trigger('change.select2');
So I need to put some '
and spaces into my string "product". How would i do that? Can i use regex?
Upvotes: 1
Views: 875