标签:text doc return cti set oct abc body 字符
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Test jQuery Extend</title> <script src="jquery-1.12.4.min.js"></script> <script> (function($){ /*类插件 usage: $.add(1,2) */ $.extend({ add: function(a,b){return a+b;}, minus: function(a,b){return a-b;} }); /*实例插件 usage: $("#name").strlen() */ $.fn.extend({ strlen: function () { return $(this).text().length; } }); })(jQuery); $(function () { console.log($.add(1,2)); console.log($.minus(1,2)); console.log(‘字符长度‘,$("#name").strlen()); }); </script> </head> <body> <div id="name">abcd123中国</div> </body> </html>
jQuery函数继承 $.extend, $.fn.extend
标签:text doc return cti set oct abc body 字符
原文地址:http://www.cnblogs.com/wucg/p/6767798.html