{# ???用jQuery写插件时,最核心的两个方法#}{# ???$.extend(object)//为jquery添加一个静态方法#}{# ???$.fn.extend(object)//为jquery实例添加一个方法#} ???$.extend({ ???????Myprint:function () { ???????????console.log(‘hello‘) ???????} ???}) ???$.Myprint()
输出标签内容$.fn.extend({ ???????Gettext:function () { ???????????//原生js写{# ???????????for(var i=0; i<$(this.length); i++){#}{# ???????????????console.log($(this[i].innerHTML)) //$(this)找到当前一个标签#}{# ???????????}#} ???????????????????????//用jquery写 ???????????$.each($(this)),function(x,y) { ???????????????console.log(y.innerHTML) ???????????} ???????} ???}); ???$(‘p‘).Gettext()
jquery扩展方法
原文地址:https://www.cnblogs.com/wangyue0925/p/9197255.html