I have a select box with 10 parameters. Each time you select an option, it sets localstorage to the value you selected with the identifier "select1".
For example: if you select the first option that you get in localstorage: Key: Emailclient - Value: Option1.
Now Iom is trying to make the value of localstorage the selected attribute on the selection form.
This is what I tried, but does not seem to work:
if (localStorage.getItem("Select1") == "Option1"){ $('#selectbox').val("Option1").attr("selected"); }
What am I doing wrong?
EDIT:
This is my code:
<select id="selectbox" > <option>Default</option> <option>Option 1</option> <option>Option 3</option> <option>Option 3</option> <option>Option 4</option> <option>Option 5</option> <option>Option 6</option> </select>
thanks
jQuerybeast
source share