Store and use an array using the HTML data tag and jQuery

后端 未结 3 2080
一生所求
一生所求 2020-12-05 02:07

I am attempting to store an array in the HTML data tag. For example:

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 02:54

    Try adding [ and ] to beginning and end (this makes it valid JSON). After doing so, you can use JSON.parse() to convert it to a native JavaScript object.

提交回复
热议问题