JavaScript Increase transform scale by javascript onclick

please help me to build following logic, here is code:

<button onclick="zoomin()">Zoom In</button>

function zoomin(){
   var myImg = document.getElementById("img");
   var i = 0;
   i++;
   myImg.style.transform = "scale(1."+ i +")";
}

but, because of i = 0 it works only one time. please tell me solution.

Answer:1
var i = 0;
var myImg = document.getElementById("img");
function zoomin(){
   i++;
   myImg.style.transform = "scale(1."+ i +")";
}

declare i=0; outside function will solve you probleem

Answer:2

I've created some sample code below. You can delete items simply by clicking the text you want to delete (or the li element). When you look at the network tab when you delete, you get back both a ...

I've created some sample code below. You can delete items simply by clicking the text you want to delete (or the li element). When you look at the network tab when you delete, you get back both a ...

My authenticate.php file is returning an object Json: [{"u_id":"1","u_name":"Nabeel" }] Here is my js: success: function(result) { var obj=$.parseJSON(result); alert(result); //[{"u_id":"1"...

My authenticate.php file is returning an object Json: [{"u_id":"1","u_name":"Nabeel" }] Here is my js: success: function(result) { var obj=$.parseJSON(result); alert(result); //[{"u_id":"1"...

I'm writing a program that calculates the price of painting rooms in a house. The program asks the user a couple of questions and the user must input certain answers regarding the topic. The program ...

I'm writing a program that calculates the price of painting rooms in a house. The program asks the user a couple of questions and the user must input certain answers regarding the topic. The program ...

  1. javascript repeat validation

as stated in the name, i have a menu with links, and i have a list of sections which i want to show/hide on the click of the menu. What i want here is to be dynamic in a sense that if i add more menus ...

as stated in the name, i have a menu with links, and i have a list of sections which i want to show/hide on the click of the menu. What i want here is to be dynamic in a sense that if i add more menus ...

  1. show content only on mobile
  2. show content only on homepage wordpress
  3. show content only from this computer
  4. wordpress show content only to logged in users
  5. tar show content only
  6. curl show content only
  7. wordpress show content only if logged in
  8. php show content only if logged in
  9. chrome show content only
  10. show my cloud-only content from onedrive
  11. show hide content css only
  12. sharepoint show page content only
  13. how to show only content in excel
  14. ie show secure content only
  15. show content only