开发者

simplest way to create an extension function using Jquery

开发者 https://www.devze.com 2023-03-05 19:35 出处:网络
What is the simplest way to create an extension function or method using Jquery. I am finding it really difficult to create my own property using Jquery.开发者_如何学JAVA

What is the simplest way to create an extension function or method using Jquery. I am finding it really difficult to create my own property using Jquery.开发者_如何学JAVA

e.g

$("#selector").myproperty({para1:val1});


The simplest way is to just create a plugin:

$.fn.myproperty = function ( opts ) {
    // within the plugin:
    // this === $('#selector')
    // opts.para1 === val1
};

when you invoke it using $('#selector').myproperty({para1:val1})

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号