zoukankan      html  css  js  c++  java
  • json与页面动态绑定

        function fnBindHtml(html, tempName, data) {
                $(html).find(tempName).each(function () {
                    var _this = this;
                    var thisNmae = _this.getAttribute('name') ? _this.getAttribute('name'):"err";
                    switch (_this.tagName) {
                        case "DIV": { _this.innerHTML = data[thisNmae]; }
                            break;
                        case "P": { _this.innerHTML = data[thisNmae]; }
                            break;
                        case "SPAN": { _this.innerHTML = data[thisNmae]; }
                            break;
                        case "INPUT": { _this.value = data[thisNmae]; }
                            break;
                        default: { _this.innerHTML = data[thisNmae]; };
                            break;
                    };
                });
                //return html;
            };
    
            function fnCreatHtml(rootid, tempName, data) {
                if (data == null || data.length == 0) { return false; }
    
                for (var i = 0; i < data.length; i++) {
                    var rootDivCope = $(rootid).eq(0).clone(true);
                    fnBindHtml(rootDivCope, tempName, data[i]);// rootDivCope =                
                    $(rootDivCope).show();
                    $(rootid).eq(0).after(rootDivCope);
                };
            }
    
            function fnShowNote(strCode, id) {
                $.ajax({
                    url: "/TraceApi/GetOneCameraInfo",
                    data: { code: strCode },
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true,//同步异步设置,false同步,true异步
                    success: function (res) {
                        if (res.code != "1000") {
                            return;
                        };
                        var modelList = res.data;
                        if (modelList == null || modelList.length == 0) { return; }
                        fnCameraNote(modelList, id);
                    }
                });
            };
  • 相关阅读:
    以太坊:用 Solidity 写测试用例
    以太坊:测试合约
    以太坊:支持 Quorum 开发
    以太坊:编写外部脚本
    以太坊:使用控制台
    以太坊:调试合约
    Rancher 2.x 搭建及管理 Kubernetes 集群
    我的友情链接
    我的友情链接
    我的友情链接
  • 原文地址:https://www.cnblogs.com/Blogs-Wang/p/10833579.html
Copyright © 2011-2022 走看看