使用script标签来做html页面的模板
来源:互联网 发布:mac修容粉香港价格 编辑:程序博客网 时间:2024/05/16 07:26
html页面经常需要js动态加载html内容,一般都采取js拼接html 的方式实现,最近发现可以使用<script>标签来做个html模板,这样更方便。并且代码可读性也增强了。
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no"><!--<meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black">--><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>script html模板</title><style>* {font-family: Arial "微软雅黑";}#addBtn{background-color: #fff;display: block;padding:3px 20px;border:1px solid #E0E0E0;color:#888;border-radius: 10px;}.list {border:1px solid pink;padding:10px}p{color: goldenrod;}</style></head><body><input type="button" value="clickMe" id="addBtn"/><div class="list"></div><script src="js/zepto.min.js"></script><script type="text/html" id="temp"><div class="item"><p>[title]</p><p>[dateA]</p></div></script><script type="text/javascript">$(function(){$("#addBtn").click(function(){console.log("sadff");var reg = new RegExp("\\[([^\\[\\]]*?)\\]", 'igm'); //i g m是指分别用于指定区分大小写的匹配、全局匹配和多行匹配。var html = document.getElementById("temp").innerHTML;for(var i=0;i<10;i++){var source = html.replace(reg, function(node, key) { return { 'title' : '我是hbuilder啊,哈哈哈哈', 'dateA' : '2016-09-19' }[key]; }); $(".list").append(source);}});});</script></body></html>
1 0
- 使用script标签来做html页面的模板
- html模板(script标签使用)
- 在HTML中使用<script>做模板
- html的script标签
- html中的a标签用js来实现页面跳转的功能(php分页时做的页面跳转)
- Script标签与访问HTML页面
- 你可以使用HTML Meta标签来做…
- 用JavaScript来验证Struts的html页面标签
- asp.net 在页面的最下面注册script脚本 html标签之外
- HTML页面元素加载顺序----Script标签在Firefox下对背景图片的影响
- HTML <script>标签的type类型
- html文件的script标签用法
- HTML <script> 标签的 src 属性
- HTML中<script ...>....</script>标签的正则表达式?
- 关于<Script>标签在html页面放置位置
- 关于<Script>标签在html页面放置位置
- 关于<Script>标签在html页面放置位置
- HTML <script> 标签
- freemarker 输出 Boolean 类型
- [TODO] LeetCode #300: Longest Increasing Subsequence
- Nginx防盗链详细设置
- Cure
- Docker监控及日志采集神器
- 使用script标签来做html页面的模板
- from表单method属性对action属性的影响
- orcale的to_number方法
- Android热修复实践应用--AndFix
- 【转】机器学习算法比较
- 通信协议——Http、TCP、UDP
- QSplitter分割界面 初始比例
- 物联网框架ServerSuperIO(SSIO)更新、以及增加宿主程序和配置工具,详细介绍
- hdu5887(搜索解01背包+奇怪的剪枝)