Cant figure do once on load
Hi there I'm a newbie to JQ but with a reasonable background in js and actionscript.
What I am trying to do is get a function to run just once when the page is first loaded adn then not again (even if the page is reloaded)
I have the quickstart guide which gives the code for a one time event handler and it says that it can apply to load like:
-
<script>$(function(){
$("target").one('click', function(event){
alert('blah blah');
});
});
</script>
now I can see how the id='target' is clicked and runs the alert just once. No problem.
But I don't see how to apply this to a document load. I have tried:
-
<script>$(function(){
$(this.document).one('load', function(event){
alert('blah blah');
});
});
</script>
and
-
<script>$(function(){
$(this).one('load', function(event){
alert('blah blah');
});
});
</script>
and
-
<script>$(function(){
$(document).one('load', function(event){
alert('blah blah');
});
});
</script>
But it's no go.
Any help from a kind soul greatly appreciated...