JSFiddle - React, Tailwind, and code Playground

HTML

<img id="semafor_slon" onclick="colorButtonsStatusChange(this.id)" style="float:left;width:16px;height:16px;background-image: url('http://agrozoo.net/img/g/semafor_slon.png'); background-position: 0px;" />

JavaScript 1.7

function colorButtonsStatusChange(id) {
  alert(id);
  el = document.getElementById(id);
  pos = parseInt(el.style.backgroundPosition);
  pos = (pos == -32) ? 0 : pos - 16;
  document.getElementById(id).style.backgroundPosition = pos.toString() + 'px';
  //alert(id);    
}