var elem = document.getElementById('add_num'), num = +elem.innerHTML; function addNum() { num++; elem.innerHTML = num; if(num == 10) { alert('Вы досчитали до 10!'); num = -1; } }