I am getting to know jQuery a little bit more. I recently created a plugin (works just fine). However, here it something that I am curious about. Suppose I have the following plugin ...
(function($){
$.fn.plugin = function(){
//code here
};
}(jQuery));
then if I use it $('#selector').plugin()
and then use it again $('#selector').plugin().method1()
it seems to create two different instances.
How can I modify my code so it still refers to the same instance given that the selector is the same, something similar to the following behaviour?
var pg = $('#selector').plugin();
pg.method1();
Thanks!