jquery 插件的编写
2016-12-16 00:00
246 查看
/**
* 插件的学习
* 原文地址: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);
* 插件的学习
* 原文地址: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插件编写
- 编写jquery扩展插件
- jQuery插件编写实用格式
- 编写jQuery插件的方法
- Jquery不同版本共用的解决方案(插件编写)
- jquery开发:jquery插件编写
- jQuery插件编写的原理
- jQuery编写动态评分小星星的插件
- JQuery插件编写
- jQuery中的插件的编写和使用
- 如何编写JQuery 插件详解
- 如何编写jQuery插件
- 编写JQuery插件示例
- 编写jQuery插件(三)——三个插件例子
- jquery插件的编写
- 编写简单的jQuery提示插件
- 用jQuery 编写自定义插件
- 基于编写jQuery的无缝滚动插件
- jQuery extend() & jQuery.fn.extend(),插件编写
- jquery编写插件