jquery添加扩展方法及为选择的对象添加方法

xiaoxiao2021-02-28  59

(function($){ //jquery类本身添加方法 //jquery扩展方法1 jQuery.extend(object); $.extend({ exalert:function(){ alert('exalert'); } }); //jquery扩展方法2   添加一个新的全局函数 $.exalert2=function(){ alert('exalert2'); } //jquery扩展方法3   使用命名空间 $.myPlu={ plu1:function(){alert('plu1')}, plu2:function(){alert('plu2')}, } //类对象添加方法 //第一种 $.fn.fun1:function(){ alert('fun1'); } $.fn.extend({ fun2:function(){ alert('fun2'); } }); })(jQuery); $.exalert(); $("#subject_group_set_subject_group_name").fun1();
转载请注明原文地址: https://www.6miu.com/read-2614324.html

最新回复(0)