Insert into HTML select tag options from a JSON

前端 未结 6 1786
甜味超标
甜味超标 2021-02-09 14:18

So, here\'s the deal: I have a JSON object saved in my web App at localStorage. This JSON is being saved as a string, with JSON.stringify, inside one of my function

6条回答
  •  生来不讨喜
    2021-02-09 15:07

    You don't need the transform for this, try it this way:

    var jsonData = $.parseJSON(window.localStorage.getItem("data"));
    
    var $select = $('#mySelectID');
    $(jsonData).each(function (index, o) {    
        var $option = $("

    Here is a working fiddle.

提交回复
热议问题