Search code examples
jqueryhtmlfunctioncall

jQuery function call in a container


So I've this:

    function pageSwap(menuPont){   
    $(".content").fadeOut("1000",function(){
            $(".content").load(menuPont, function(){
                $(".content").fadeIn("5000");
            });       
    });
}

on index.php, and also this

    $(".content").ready(function(){pageSwap('main.html')});

Both work and stuff, but my problem is, that I need to call a pageSwap('other.html')
IN THE .content div, link style.

I couldn't get this working, so please help me. :[


Solution

  • I am not entirely sure what want to accomplish, but I assume that you want to call pageSwap('other.html'), when someone clicks on the .content div?

    $(function(){
      pageSwap('main.html');
      $('.content').click(function(){
        pageSwap('other.html');
      }
    });
    

    UPDATED with the solution from the comments: To call the pageSwap('other.html') when clicking on a link within the container, put the function call into the href:

    <a href="javascript:pageSwap('other.html');">my link</a>