Single quotes in data attribute containing json

前端 未结 5 1408
清酒与你
清酒与你 2021-02-12 21:06

Cosmetic question: I have a html element containing possible dimensions for some embedded images, these are stored as:

5条回答
  •  广开言路
    2021-02-12 21:52

    Try this and you can keep nicely formatted JSON in the attribute:

    $.parseJSON($('.inside').data('dimensions').replace(/'/g,"\""))
    

提交回复
热议问题