dips is a multiple select drop down menu and dips_list is an array containing some of the drop down menu values I want selected using the code below:
jQuery.each(dips_list, function(index,value){
jQuery("#dips option[value='" + value + "']").attr("selected", 1);
jQuery("#dips").multiselect("refresh");
});
Here’s how the drop menu looks like:
<select id="dips" name="dips" multiple="multiple" size="10">
<option value="">Choose IP Address</option>
<option value="127.0.0.1">127.0.0.1</option>
<option value="127.0.0.2">127.0.0.2</option>
<option value="127.0.0.3">127.0.0.3</option>
<option value="127.0.0.4">127.0.0.4</option>
</select>
But, it does not work. Any idea why?
You should replace
with
or if your using jQuery 1.6 =>
Docs for .prop()