如何创建一个jQuery函数(一个新的jQuery方法或插件)?我知道在JavaScript中语法如下:function myfunction(param){
//some code}有没有办法在jQuery中声明一个可以添加到元素中的函数?例如:$('#my_div').myfunction()
3 回答
慕田峪9158850
TA贡献1794条经验 获得超8个赞
你总是可以这样做:
jQuery.fn.extend({
myfunction: function(param){
// code here
},});OR
jQuery.extend({
myfunction: function(param){
// code here
},});$(element).myfunction(param);添加回答
举报
0/150
提交
取消
