how can i invoke a function after page is done loading? (and only then..)

i’m having trouble with some jquery code.
in my html page i use ajax to get some info, and then i’m changing an html element
with $ (“#id”).html(…)

the problem is, i also have a $ (document).ready code which i wanna call only once
when the page is done loading, but after each change in the html with the $ (“#id”).html(…)
the code is called once again.
how can i run the $ (document).ready code only once?

here is an example:

$  (document).ready(function(){
// this code will run not only once...
}

function f(){
$  ("#id").html(...);
}

Thanks.

newest questions tagged jquery – Stack Overflow

About Admin