I want to run the function only when loading the div.
When I load the page, several files load. At the end of the list, PHP has something in common with a div. When this is displayed, jQuery should run the function.
I can do this with the click event, but I want it to work automatically without clicking a button.
Here's how it works with a click:
$("#PP_end_show").live("click",function(){ $("#PP_head_bar").slideToggle("slow"); $("#PP_info_file_wrap").slideUp("slow"); });
This is a div repeated by PHP:
<?php echo "<div id=\"PP_end_show\"></div>"; ?>
The output is generated after an AJAX call:
<form id="PP_search_input" method="post" name="search_ID" ONSubmit="xmlhttpPost('PP_search_stream_client.php', 'PP_search_input', 'PP_thumb_output', '<img src=\'images/wait.gif\'>');return false; "> <input name="search_string" type="text" class="PP_input" id="search_string" value="<?php echo $_POST['search_string']; ?>"/> <button type="submit" class="PP_submit" id="search_submit"> search </button>
at the end of the generated output, a specific div will be printed and should call a new jQuery function.
Joost source share