标签:style blog http io color ar 使用 java for
jQuery插件的开发包括两种:类级别的插件开发和对象级别的插件开发。
jQuery.ABC = function () { alert(‘this is my first extent Program!!‘); }
jQuery.AAA = function () { alert(‘this is my first extent Program!!‘); } jQuery.BBB = function (param) { alert(‘this is my first extent Program!!‘ + param); }
jQuery.BBB(‘123‘);
jQuery.extend({ CCC: function () { alert(‘this is my first extent Program!!‘); }, DDD: function (param) { alert(‘this is my first extent Program!!‘ + param); } })
jQuery.MyExtent = { EEE: function () { alert(‘this is my first extent Program!!‘); }, FFF: function (param) { alert(‘this is my first extent Program!!‘ + param); } }
$.MyExtent.FFF(‘123‘);
$(function ($) { $.fn.extend({ AAA: function () { //coding...... } }) })(jQuery);
$(function ($) { $.fn.FirstExtens=function(){ //coding } }) })(jQuery);
$(function ($) { $.fn.No2 = function (options) { var defaults = { name: ‘小李‘, age: 32 }; var opt = $.extend(defaults, options); alert(opt.name + ‘‘ + opt.age); } })(jQuery);
$("#tt1").No2({ name: ‘张三‘ });
$(function ($) { $.fn.No2 = function (options) { var opt = $.extend({}, $.fn.No2.defaults, options); alert(opt.name + ‘‘ + opt.age); } $.fn.No2.defaults = { name: ‘小李‘, age: 32 }; })(jQuery);
$.fn.No2.defaults.name = ‘长三‘; //可以这样调用设置值 $("#tt1").No2(); //调用方法
$(function ($) { $.fn.No2 = function (options) { var opt = $.extend({}, $.fn.No2.defaults, options); return this.each(function () { var $this = $(this); var content = $this.text(); content = content + ‘--此处已经修改--‘; $this.text(content); $.fn.No2.format(opt); }) } $.fn.No2.defaults = { name: ‘小李‘, age: 32 }; $.fn.No2.format = function (option) { alert(‘Hi, My name is ‘ + option.name + ‘,I\‘m ‘ + option.age + ‘year old...‘); } })(jQuery);
$.fn.No2.defaults.name = ‘张三‘; //可以这样调用设置值 $("#tt1").No2({ name: ‘老王‘ //覆盖设置的值 }); $.fn.No2.format({ //暴露的函数,可以直接在外部调用 name: ‘火龙果‘, age: ‘1‘ });
标签:style blog http io color ar 使用 java for
原文地址:http://www.cnblogs.com/yangda/p/4063992.html