/**
* 插件的学习
* 原文地址: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);
相关文章
- jQuery中的表单对象属性过滤选择器(四、八)::enabled、:disabled、:checked、:selected
- jQuery中的属性过滤选择器(四、五):[attribute] 、[attribute=value]、[attribute!=value] 、[attribute^=value] 等
- 2.编写IoDemo.java的Java应用程序,程序完成的功能是:首先读取text.txt文件内容,再通过键盘输入文件的名称为iodemo.txt,把text.txt的内容存入iodemo.txt
- 编写一个程序,打印输入中单词长度的直方图。
- 深入学习jquery源码之继承框架的实现
- 深入学习jquery源码之创建科学、复用率高的对象
- 深入学习jquery源码之jQuery的二次开发
- 深入学习jquery源码之插件机制(二)
- Elasticsearch插件开发指南:如何扩展Elasticsearch的功能
- 编写高效的Java代码:常用的优化技巧【四】之并发编程技巧