I used a code:
jQuery.fn.MyFunction = function(){
return this.each(function() {
attributes = "test";
return attributes;
});}
But when I call
var1 = $(this).MyFunction();alert(var1);
I got an [object], but not the “test”.
How to allow jquery plugin return a some value?
jQuery plugins are generally designed to return a jQuery object so you can chain method calls:
If you want to return something else, use the following syntax:
, or access it via its index using
[].