There are several ways to do this.
Firstly, you can use a marker and then delete it:
<div id="mydiv" class="not-initialized">
...
</div>
from:
$("#mydiv").click(function() {
if ($(this).hasClass("not-initialized")) {
$(this).removeClass("not-initialized");
} else {
$(this).toggle();
}
});
Secondly, you can change the event handlers:
$("#mydiv").click(append_content);
function append_content() {
...
$("#mydiv").unbind("click", append_content).click(toggle_display);
}
function toggle_display() {
$(this).toggle();
}
, div, , .