문제

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
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top