I have a select box with 10 options. Each time you select an option it sets in the localstorage the value you selected with id "select1".
For example: If you select the first option you get in the localstorage: Key: Emailclient - Value: Option1.
Now, Iom trying to make the value of the localstorage, the selected attribute in the select form.
This is what I tried but doesn't seem to work:
if (localStorage.getItem("Select1") == "Option1"){
$('#selectbox').val("Option1").attr("selected");
}
What I'm 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