Pergunta

I have a select with some options.

I also have a function that when the option changes it saves it to local storage

input1save = $('#answer1 option:selected').val
localStorage['ScienceSkills-QuestionsTest-1-1421-6845-5309-4850-5124'] = input1save     

When the page reloads I have a function where an alert is shown with the value of the option (using local storage)

input1save = localStorage['ScienceSkills-QuestionsTest-1-1421-6845-5309-4850-5124']
alert(input1save);

However it alerts with alot of random code instead of the value

I know the save function works because if I use

 input1save = "foo"

It alerts "foo"

Therefore the problem comes from

 $('#answer1 option:selected').val
Foi útil?

Solução

$('#answer1 option:selected').val()

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top