1. 程式人生 > >插件擴展的幾種方法

插件擴展的幾種方法

ext 方法 script UNC text console tex col ole

<script> //第一種:擴展Jquery原型對象的方法 (function($) { $.fn.logText = function() { console.log(this.text()); } })(jQuery); $(function() { //自定義的原型方法,也就是jquery插件 $(".text01").logText(); });
//第二種:擴展jquery構造函數上的插件(方法) $.extend({ logTime: function() { console.log(new Date()); } }); var s = $.logTime(); </script>

插件擴展的幾種方法