<button onclick=f(this)>click me</button> <script> function f(t){if(t.i){t.i=0;f1()}else{t.i=1;f2()}}; function f1(){alert('one')}; function f2(){alert('two')}; </script>