simplest way to create an extension function using Jquery
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})
精彩评论