标签:
<script> (function($) { //默认配置 var defaults = { text:‘默认的文字‘, }; //主程序 $.fn.writeSome = function(options){ //合并配置 var opt = $.extend(defaults,options); //执行 this.append(opt.text); //返回JQ选择对象 return this; }; })(jQuery); </script> <h1 class="WriteText"></h1> <script> $(‘.WriteText‘).writeSome(); $(‘.WriteText‘).writeSome({ text:‘nihao‘, }).css(‘color‘,‘red‘); </script>
标签:
原文地址:http://my.oschina.net/miaowang/blog/479666