Bind JSON object to HTML element

前端 未结 6 643
自闭症患者
自闭症患者 2020-12-31 13:29

I want to bind a JSON object to a HTML element.

e.g.

I have a object \"person\" with the attributes \"firstName\", \"lastName\"

6条回答
  •  独厮守ぢ
    2020-12-31 13:40

    Simple one-way approach using jquery...

        var resp = your_json_data;
        $(function () {
            $(".jsondata").each(function () {
                $(this).html(eval($(this).attr("data")));
            });
        });
    

    then in the page...

     
    

提交回复
热议问题