Javascript/jQuery: Set Values (Selection) in a multiple Select

Iterate through the loop using the value in a dynamic selector that utilizes the attribute selector.

var values="Test,Prof,Off";
$.each(values.split(","), function(i,e){
    $("#strings option[value="" + e + ""]").prop("selected", true);
});

Working Example http://jsfiddle.net/McddQ/1/

Leave a Comment