zoukankan      html  css  js  c++  java
  • JS 模板

    function init() {
    var DATAJson=JSON.parse(DATA);

    var sort=DATAJson.sort(function(a,b){
    	return a.status>b.status?-1:1
    });
    //console.log(sort);	
    String.prototype.temp = function(obj) {   //替换$$里面的内容
        return this.replace(/$w+$/gi, function(matchs) { //
            var returns = obj[matchs.replace(/$/g, "")];	//匹配json中每个以$开头的
            return (returns + "") == "undefined"? "": returns;
        });
    };
    var htmlList = ''
        , htmlTemp = $("ul").html();
    //console.log(htmlTemp.temp(DATAJson));
    DATAJson.forEach(function(item) {
         htmlList += htmlTemp.temp(item);
    });
       $("ul").html(htmlList);
    
      $("#DONE").empty().html("未完成");
    }	
    

    网上抄的模板,注意正则!!!

    var DATAJson=JSON.parse(DATA);
    var sort=DATAJson.sort(function(a,b){
    	return a.status>b.status?-1:1
    });
    //console.log(sort);	
    String.prototype.temp = function(obj) {   //替换$$里面的内容
        return this.replace(/$w+$/gi, function(matchs) { 
            var returns = obj[matchs.replace(/$/g, "")];	//匹配json中每个以$开头的
            return (returns + "") == "undefined"? "": returns;
        });
    };
    var htmlList = ''
        , htmlTemp = $("ul").html();
    //console.log(htmlTemp.temp(DATAJson));
    DATAJson.forEach(function(item) {
         htmlList += htmlTemp.temp(item);
    });
       $("ul").html(htmlList);	
      $("#DONE").empty().html("未完成");
    }
  • 相关阅读:
    4.C#的选择语句练习
    3.C#中的选择语句
    java包静态导入,继承
    新的学期要继续学习喽
    桌球小游戏
    JAVA和C语言的区别
    BIV+CSS网页的标准化布局
    层叠样式表
    学PHP也要懂得HTML
    web开发入门
  • 原文地址:https://www.cnblogs.com/liuestc/p/5680131.html
Copyright © 2011-2022 走看看