The intent of your code is not very clear. The design of your plugin
can vary a great deal depending on its purpose. Typically, however, I
use a format similar to:

// put in a closure and make jQuery available as $
(function ($) {
        // define a function that can be called on a jQuery object
        $.fn.myFunction = function (args) {
                // return the object (to maintain chain)
                return this.each(function () {
                        // do stuff here
                });
        };

        // private functions
        function myPrivateFunc() {

        }
})(jQuery);

// to call
$("#id").myFunction("your_args_here");

Hope that helps some ;)

On Nov 24, 10:44 am, howa <[EMAIL PROTECTED]> wrote:
> Codes...
>
> jQuery.test = function(val) {
>
>     jQuery.test.foo = function() {
>        alert( "foo" + jQuery.test.bar()  );
>     };
>
>     jQuery.test.bar = function() {
>        return "bar" +val;
>     };
>
>     jQuery(document).ready(function() {
>
>             jQuery.test.foo();
>
>     });
>
> };
>
> // To use
>
> <script>
>
> jQuery.test("Tom");
>
> </script>
>
> Is  my style of writing jQuery plugin correct?
>
> Thanks for comments...

Reply via email to