Passing JSON data from php to html-data attribute and then to Javascript

后端 未结 1 1458
礼貌的吻别
礼貌的吻别 2021-01-01 10:48

i\'m creating a plugin in which the user adds custom settings in data- attribute in HTML. Settings are in JSON format. I\'m using these settings in Javascript.<

1条回答
  •  情话喂你
    2021-01-01 11:07

    You need to escape data and handle special characters.

    And get it with jQuery:

    $('[data-side="front"]').data('params'); // object
    

    0 讨论(0)
提交回复
热议问题