Insert into HTML select tag options from a JSON

前端 未结 6 991
南方客
南方客 2021-02-09 14:32

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:01

    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.

提交回复
热议问题