Try using this to create the plugin:

(function($) {
    //
    // plugin definition
    //
    $.fn.dockBar = function(options) {

        // build main options before element iteration
        var opts = $.extend({}, $.fn.dockBar.defaults, options);

        // iterate and reformat each matched element
        return this.each(function() {
            $this = $(this);

            $this.mouseover(function() {
                $this.animate({height: 100, width:100}, "medium");
                $this.attr('src', 'Icons/' + opts.fileName + '1.png');
                }).mouseout(function() {
                $this.animate({height: 80, width:80}, "medium");
                $this.attr('src', 'Icons/' + opts.fileName + '2.png');
                });
        });

    //
    // plugin defaults
    //
    $.fn.dockBar.defaults = {
        fileName: ''
    };
    };

})(jQuery);


You can then use it like this:

$("#MyDiv").dockBar({
     fileName: 'FILENAME'
});

Let me know how that works for you.

-Tim

On Oct 26, 10:09 pm, jcnconnect <[EMAIL PROTECTED]> wrote:
> Hi, im trying to make a custom jquery plugin but i need some help.
> Here is the function that i am trying to do, but i dont want to repeat this
> a million times
> through out the website.
>         $('#MyDiv').mouseover(function() {
>                 $('#MyDiv').animate({height: 100, width:100}, "medium");
>                 $('#MyDiv').attr('src','Icons/MyDivImage1.png');
>                 }).mouseout(function() {
>                 $('#MyDiv').animate({height: 80, width:80}, "medium");
>                 $('#MyDiv').attr('src','Icons/MyDivImage2.png');
>                 });
>
> I look up on a tutorial to make jQuery plugins but when i made my plugin i
> couldnt get it to work.
> Here is the plugin that i made.
>
> jQuery.fn.DockBar = function(DivName,FileName) {
>         DivName = '#' + DivName;
>         $(NameRev).mouseover(function() {
>                 $(DivName).animate({height: 100, width:100}, "medium");
>                 $(DivName).attr('src', 'Icons/' + FileName + '1.png');
>                 }).mouseout(function() {
>                 $(DivName).animate({height: 80, width:80}, "medium");
>                 $(DivName).attr('src', 'Icons/' + FileName + '2.png');
>                 });
>
> };
>
> Any ideas, thanks.
> --
> View this message in 
> context:http://www.nabble.com/Custom-plugin-tp20181134s27240p20181134.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to