JS Beispiel
<button onClick="ff()" id='but' style="color:white; padding:0.08in; width:2in"></button>
<script>
function ff(){
// initialize
if( this.state == null ){
this.state = { color: 'green', label: 'free' };
return apply(this.state);
}
// FlipFlop
this.state =
this.state.color == 'green'
? { color: 'red', label: 'occupied' }
: { color: 'green', label: 'free' };
apply(this.state);
}
function apply(state){
document.getElementById('but').innerHTML = state.label;
document.getElementById('but').style.backgroundColor = state.color;
}
window.onload = function(){ ff() };
</script>