How do we store a string in localStorage?

后端 未结 4 1262
梦如初夏
梦如初夏 2021-01-13 19:14

I\'m learning javascript, xml, and html. For a homework assignment, I need to retrieve some data from some nodes of a XML file, concatenate the data, and store the concaten

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-13 19:49

    You are not setting the data, you are getting the data that doesn't exist

    I believe what you want is this

    (You have to give a name to the variable in local storage, I'm giving it the name of students)

    localStorage['students'] = students;
    $("#clickme").text("Students' first names: " + students);
    

    After this you can have your get if you want similar to what you had before

    var s_data = localStorage['students'];
    

提交回复
热议问题