jquery-jtemplates.js下载地址:https://gitee.com/nelsonlei/jquery-jtemplates.jsMoBanYingYong

  

 <!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery-jtemplates.js"></script>
<style type="text/css">
.container {
width: 1000px;
height: 600px;
margin: 0 auto;
} .template {
display: none;
} table {
background-color: #fff;
} table tr th {
padding: 8px;
border-bottom: 1px solid #eee;
} table tr td {
padding: 10px;
border-bottom: 1px solid #eee;
}
</style>
</head>
<body>
<div class="container"> <!--内容展示区-->
<div id="result"></div> <!--渲染处理区,textarea为必须元素,display:none-->
<textarea id="template" class="template">
<div>部门编号:{$T.list_id}</div>
<div>部门负责人:{$T.name}</div>
<div>
<table>
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>邮箱</th>
<th>性别</th>
</tr> <!--渲染的关键句,类似于for循环-->
{#foreach $T.table as record}
<tr>
<td>{$T.record.id}</td>
<td>{$T.record.name}</td>
<td>{$T.record.age}</td>
<td>{$T.record.mail}</td>
<td>{$T.record.sex}</td>
</tr>
{#/for}
<!--渲染的关键句,类似于for循环-->
</table>
</div>
</textarea> <div style="width: 100%;margin: 4rem 0;">------------上面是多维数组,下面是单维数组----------</div> <div id="result1"></div>
<textarea id="template1" class="template">
<div>
<table>
<tr>
<th class="Number">编号</th>
<th>姓名</th>
<th>年龄</th>
<th>邮箱</th>
<th>性别</th>
</tr> <!--渲染的关键句,类似于for循环-->
{#foreach $T as record}
<tr>
<td>{$T.record.id}</td>
<td>{$T.record.name}</td>
<td>{$T.record.age}</td>
<td>{$T.record.mail}</td>
<td>{$T.record.sex}</td>
</tr>
{#/for}
<!--渲染的关键句,类似于for循环-->
</table>
</div>
</textarea> </div> <script>
var data = {
"name": "网马伦",
"list_id": 89757,
"table": [
{"id": 1, "name": "Rain", "age": 22, "mail": "admin@domain.com","sex":"man"},
{"id": 2, "name": "皮特", "age": 24, "mail": "123456@domain.com","sex":"man"},
{"id": 13, "name": "卡卡", "age": 20, "mail": "112233@domain.com","sex":"man"}
]
}; $("#result").setTemplateElement("template"); $("#result").processTemplate(data); var table=[
{"id": 13, "name": "卡卡", "age": 20, "mail": "112233@domain.com","sex":"man"},
{"id": 4, "name": "戏戏", "age": 26, "mail": "0147@domain.com","sex":"man"},
{"id": 5, "name": "一揪", "age": 25, "mail": "kkw@domain.com","sex":"man"}
]
$("#result1").setTemplateElement("template1"); $("#result1").processTemplate(table); </script>
</body>
</html>

  效果如下:

  

jquery-jtemplates.js模板应用的更多相关文章

  1. jquery jtemplates.js模板渲染引擎的详细用法第三篇

    jquery jtemplates.js模板渲染引擎的详细用法第三篇 <span style="font-family:Microsoft YaHei;font-size:14px;& ...

  2. jquery jtemplates.js模板渲染引擎的详细用法第二篇

    jquery jtemplates.js模板渲染引擎的详细用法第二篇 关于jtemplates.js的用法在第一篇中已经讲过了,这里就直接上代码,不同之处是绑定模板的方式,这里讲模板的数据专门写一个t ...

  3. jquery jtemplates.js模板渲染引擎的详细用法第一篇

    jquery jtemplates.js模板渲染引擎的详细用法第一篇 Author:ching Date:2016-06-29 jTemplates是一个基于JQuery的模板引擎插件,功能强大,有了 ...

  4. jquery.tmpl.js 模板引擎用法

    1.0 引入: <script src="/js/jquery.tmpl.min.js"></script> 2.0 模板: <script type ...

  5. Jquery 模板插件 jquery.tmpl.js 的使用方法(1):基本语法,绑定,each循环,ajax获取json数据

    jquery.tmpl.js 是一个模板js  ,主要有2个方法 (1):$.template()方法,将一段script或者是Html编译为模板,例如 $.template('myTemplate' ...

  6. jquery的一个模板引擎-zt

    jQuery-jTemplate.js下载:http://jtemplates.tpython.com/ 一 , 简单介绍 它是一个基于jQuery开发的javascript模板引擎.它主要的作用如下 ...

  7. jquery.validate.js插件使用

    jQuery验证控件jquery.validate.js使用说明+中文API 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-valid ...

  8. 【PC端】jQuery+PHP实现浏览更多内容(jquery.more.js插件)

    参数说明: 'amount' : '10', //每次显示记录数 'address' : 'comments.php', //请求后台的地址 'format' : 'json', //数据传输格式 ' ...

  9. jquery.validate.js在IE8下报错不运行

    因为项目要表单验证,所以特意去找了jquery.validate这个应该是jquery官方团队出品的表单验证插件. 实际应用时,却在IE8调试时碰到了问题. 从jquery.validate官网下载了 ...

  10. 掌握js模板引擎

    最近要做一个小项目,不管是使用angularjs还是reactjs,都觉得大材小用了.其实我可能只需要引入一个jquery,但想到jquery对dom的操作,对于早已习惯了双向绑定模式的我,何尝不是一 ...

随机推荐

  1. odoo开发 相关知识点

    (1)导入模块可以起别名: (2) 新的模型前端要调用显示有关联的另一个模型的相关字段 (3) 传递上下文 搜索视图打开默认按照接收的参数搜索显示: 发起端视图 上下文写法: 目标端 触发显示,搜索视 ...

  2. 谈谈Linux下的数据流重定向和管道命令

    一.标准输入.标准输出.错误输出概述 1.标准输入(stdin)是指令数据的输入,代码为0,使用<或者<<,默认是键盘. 2.标准输出(stdout)是指令执行成功返回的结果,代码为 ...

  3. Vue中使用watch来监听数据变化

    写法一: methods:{ //监听isMD upProp(){ if(this.isMD){//如果isMD等于true 就把storeManagerName赋值给isStoreManagerNa ...

  4. Python学习--02输入和输出、运算符

    命令行输入 x = input("Please input x:") y = raw_input("Please input x:") 使用input和raw_ ...

  5. centos 修改时区

    # date 2014年 07月 22日 星期二 :: EDT # cat /etc/sysconfig/clock -------------------------- ZONE="Ame ...

  6. offsetTop、offsetLeft、offsetWidth、offsetHeight的用法

    假设 obj 为某个 HTML 控件. obj.offsetTop 指 obj 相对于版面或由 offsetParent 属性指定的父坐标的计算上侧位置,整型,单位像素. obj.offsetLeft ...

  7. Solr 配置中文分词器 IK

    1. 下载或者编译 IK 分词器的 jar 包文件,然后放入 ...\apache-tomcat-8.5.16\webapps\solr\WEB-INF\lib\ 这个 lib 文件目录下: IK 分 ...

  8. jQuery 各类判断函数汇总

    欢迎访问我的github:huanshen,有我的源码解析 常用的判断函数有type,isEmptyObject,isFunction,isWindow,isPlainObject,isArrayli ...

  9. 浅析 JavaScript 链式调用

    对$函数你已经很熟悉了.它通常返回一个html元素或一个html元素的集合,如下: function$(){ var elements = []; for(vari=0,len=arguments.l ...

  10. [转]Bootstrap table 分页 In asp.net MVC

    本文转自:https://www.cnblogs.com/lenovo_tiger_love/p/7474403.html 中文翻译文档: http://blog.csdn.net/rickiyeat ...