Json2Html

function Json2Html(data) {
var objData = $.parseJSON(data);
var tzdiv = document.createElement("div");
var ul = document.createElement("ul");
tzdiv.appendChild(ul);  
    $.each(objData, function (index, item) {
        var li = $("<li>").css({float:"right",width:"25%","list-style":"none",margin:"0 0 0 -1px"}).text(item.NAME).appendTo(ul);       
var chk = $("<input type='checkbox'/>").attr({ "id":item.ID, "value": item.NAME}).appendTo(li);
    }); //$.each函数  
    return tzdiv;
}
posted @ 2019-01-05 15:38  大虎1  阅读(443)  评论(0编辑  收藏  举报