Please help me solve the following. For example I have the following listmultiple
<select multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
How do I make it so that when I load the form some selected ones already appear usingjquery
Try first to add an ID to the select to make it easy to work with jQuery. after this you can use the function
$.each()
.Look at an example.
html:
jQuery:
Try it and tell me :)
You can call the val method and assign a
array
that will contain the values to select