最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
arttemplate的jQuery帮助方法
时间:2022-06-25 17:26:07 编辑:袖梨 来源:一聚教程网
需支持es5,兼容可以使用es5-shim
/**
* 封装模板使用方法
* @param {string} tplName 模板名
* @param {[type]} data 传入模板的数据
* @param {[type]} method dom操作方法,默认使用html()方法
* @return {[type]} 容器jQuery对象
*/
$.fn.tpl = function (tplName, data, method) {
data = data || {};
method = method || 'html';
return this[method](template(tplName, data));
};
['append', 'prepend', 'after', 'before'].map(function (method) {
(function (method) {
$.fn[method + 'Tpl'] = function (tplName, data) {
return this.tpl(tplName, data, method);
}
})(method);
});
相关文章
- 星球重启抗辐布获取方法 抗辐布怎么做 11-28
- 星球重启化纤布获取方法 化纤布怎么做 11-28
- 星球重启开普勒港在哪 开普勒港位置一览 11-28
- dnf神界版本剑魂毕业装备选择搭配攻略 11-28
- 饥荒联机版冰钓洞出现方法 冰钓洞怎么生成 11-28
- dnf徐福记联动定制光环外观一览 11-28