need to call jquery in head section after load

need to call jquery in head section after load

Hello,

I have a webpage which allows the user to select the content they would like to display using ajax to do this. the problem i have is that one display option is a file tree which only works when loaded in the head section. the following code is loaded in the head section:

$(document).ready( function() {
   
    // Hide all subfolders at startup
    $(".php-file-tree").find("UL").hide();
   
    // Expand/collapse on click
    $(".pft-directory A").click( function() {
        $(this).parent().find("UL:first").slideToggle("medium");
        if( $(this).parent().attr('className') == "pft-directory" ) return false;
    });

});

i am new to ajax and cannot figure out whether or not i can adjust the code to load only when the ajax call to the file tree is made.

any ideas?

Regards


Andy