Hi everyone, I'm not a big expert at jQuery, but I'm good at copying code, like most coders ;)
Anyway, I wrote a little object that seems to work fine, however, outside this object i need to call one of its methods, what is the correct way to do that? This is the structure of my object: ( function( $ ) { jQuery.fn.myObject = function() { return this.each( function () { // do some stuff this.method = function () // do some stuff }; } ); }; } )( jQuery ); and from outside of the object i do: var ref = $( "#someElement" ).myObject(); Later, I call the method of my object this way: ref[ 0 ].method(); But I'm sure there's a better way to do it, could someone redirect me to the right resources or tell me what structure i should use? Thanks!