function red() { var elem = document.getElementById('red_num'); elem.style.color = +elem.innerHTML ? 'green' : 'red'; }