最新下载
热门教程
- 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);
});
相关文章
- 伊瑟海因里希技能加点及搭配推荐 10-18
- 永远的蔚蓝星球遗迹夺宝第6关攻略 10-18
- 新三国志曹操传野猪毁田二关卡攻略 10-18
- 龙族卡塞尔之门影镰恺撒技能介绍 10-18
- 龙魂旅人阿瑞斯阵容搭配推荐 10-18
- 伊瑟弥瑟亚技能加点及搭配推荐 10-18