You are here: irt.org | FAQ | JavaScript | Function | Q936 [ previous next ]
Try:
<script language="JavaScript"><!--
var bool=false;
function not() { return (bool = !bool); }
alert(not());
alert(not());
alert(not());
alert(not());
//--></script>Although you don't really need a function for this, just:
<script language="JavaScript"><!-- var bool=false; alert(bool = !bool); alert(bool = !bool); alert(bool = !bool); alert(bool = !bool); //--></script>