 <pre><code>var i = 0; var myImg = document.getElementById("img"); function zoomin(){ i++; myImg.style.transform = "scale(1."+ i +")"; } </code></pre> <p>declare i=0; outside function will solve you probleem</p>