Grow your CSS skills. Land your dream job.

Transfom an anonymous jQuery function to a nammed function

  • # December 29, 2009 at 7:22 am

    Hi everyone !!

    I’m making a new website full Ajax with jQuery
    The main page is composed by 9 squares, each square represents a section
    when i click on square, a new page is loaded into within the 9 squares

    However, i would like to create a function like

    Code:
    function DivToLoad (par1,par2,par3){

    }

    As i use jQuery, i use anonymous function and i must repeat the code for every square (wich is very heavy)

    here is the code i would like to transform

    Code:
    var square2 = $(‘#square2′) //the div to click

    $(square2).fadeOut(500,function(){

    $(this).css(‘background’,'none’)

    .load(‘pageToLoad1.html #divToLoad_A_2′, function(){ // I load an external div in this square

    $(square2).fadeIn(’1000′);

    }); return false;

    });

    If a had i nammed function
    i would only write

    Code:
    DivToLoad(par1,par2,par3)

    Thanks Everyone !
    I would be very Gratefull !

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".