Cheers Sam,
That doesn't make a lot of sense to my I have to be honest.
1. Why are you starting with (function($)
2. Why $.fn inside this block? why not jQuery.fn
3. What's (jQuery) on the end of the function?
Sorry... OO Javascript is a whole new world of Pain for me! :)
Thanks
Tom
On 14/03/07, Sam Collett <[EMAIL PROTECTED]> wrote:
On 14/03/07, Tom Holder <[EMAIL PROTECTED]> wrote:
> Bit of a simple question this I'm sure but how do I scope a variable to
a
> plugin I'm creating and not expose it beyond my plugin? I do want the
> variable to be accessible to all the methods in my plugin though.
>
> Thanks
> Tom
You could write your plugin like this:
(function($) {
var myvar = "Element number: ";
$.fn.myplugin = function() {
return this.each( function(i) {
alert(myvar + i);
});
}
})(jQuery);
alert(myvar); // undefined
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
--
Tom Holder
Technical Director
SimpleWeb Limited
Great websites. Low cost. No catch.
http://www.simpleweb-online.co.uk/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/