jquery 插件的编写
/**
* 插件的学习
* 原文地址:http://www.cnblogs.com/Wayou/p/jquery_plugin_tutorial.html#home
*/;(function($, window, document,undefined) {
//定义Beautifier的构造函数
var Beautifier = function(ele, opt) {
this.$element = ele,
this.defaults = {
'color': 'red',
'fontSize': '12px',
'textDecoration': 'none'
},
this.options = $.extend({}, this.defaults, opt)
}
//定义Beautifier的方法
Beautifier.prototype = {
beautify: function() {
return this.$element.css({
'color': this.options.color,
'fontSize': this.options.fontSize,
'textDecoration': this.options.textDecoration
});
}
}
//在插件中使用Beautifier对象
$.fn.myPlugin = function(options) {
//创建Beautifier的实体
var beautifier = new Beautifier(this, options);
//调用其方法
return beautifier.beautify();
}
})(jQuery, window, document);
最新文章
- Python之路-python数据类型(列表、字典、字符串、元祖)操作
- UESTC 900 方老师炸弹 --Tarjan求割点及删点后连通分量数
- 字符串去掉空格 trim()方法
- 小白日记34:kali渗透测试之Web渗透-扫描工具-Burpsuite(二)
- 也用 Log4Net 之将日志记录到数据库的配置 (一)
- 如何在 Linux 终端下创建新的文件系统/分区
- 【转】web开发需要知道的事情
- CString常用操作
- Redis操作命令大全(NodeJS版)
- SQL XML process
- Android 蓝牙开发(整理大全)
- javascript 动态创建tip图片提示
- 部署openstack的官网文档解读mysql的配置文件
- 登陆页、注册页、会员中心页logo图的替换
- JavaScript-DOM(2)
- python---面对对象的三大特征
- 【紫书】Ordering Tasks UVA - 10305 拓扑排序:dfs到底再输出。
- Nginx 连接限制和访问控制Nginx 连接限制和访问控制
- 主成分分析(PCA)算法,K-L变换 角度
- maven 安装下载与配置 代理设置 《解决下载慢问题》