jq封装插件

$(function(){
	// $.extend()拓展方法:
	$.extend({
		backgroundColor:function(){
			$('body').css('background','#ccc');
		}
	})
	$.backgroundColor();//----->就可以调用;
})


$(function(){
	// $.fn.extend() jq对象的拓展方法:
	$.fn.extend({
		color:function(){
			$(this).css('color','red');
		},
		bg:function(){
			$(this).css('background','red');
		}
	})
	$('#txt').bg();//----->就可以调用;
})

  

原文地址:https://www.cnblogs.com/liubingyjui/p/11171272.html