Get a free trial // 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

    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

    var square2 = $(‘#square2’) //the div to click



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


    }); return false;


    If a had i nammed function
    i would only write


    Thanks Everyone !
    I would be very Gratefull !

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed