更新时间:2023-11-20 23:10:34
从 Docs :
(function($){
$ .fn.myfunction =函数(){
alert('hello world');
return this;
};
})(jQuery);
然后你做了
pre> $( '#my_div')myfunction的();
I know that in JavaScript the syntax is as follows:
function myfunction(param){
//some code
}
Is there a way to declare a function in jQuery that can be added to an element? For example:
$('#my_div').myfunction()
From the Docs:
(function( $ ){
$.fn.myfunction = function() {
alert('hello world');
return this;
};
})( jQuery );
Then you do
$('#my_div').myfunction();