I wanted to make a website where when I click on the image it doubles in size and width, but can only do it once, and if you do more, a warning will appear to prevent it. Likewise, if it is in the default size, you can not decrease it, and a warning will appear, but if you increase it and try to decrease it, it will be possible.
I stopped in the code here:
function passar(img){
var d = 0;
if (d == 0){
var x = confirm("tem certeza que deseja aumentar a imagem?");
if(x == true && d ==0){
d=d+1;
img.height=img.height*2;
img.width=img.width*2;
}
else if (x== true && d==1)
window.alert("Não é possivel aumentar mais");
else{
var y = confirm("tem certeza que deseja diminuir a imagem?");
if ( y==true && d==1){
d=d-1;
img.height=img.height/2;
img.width=img.width/2;
}
else if(y == true && d==0)
window.alert("Não é possivel");
}}}
My biggest problem is that when a if-else
closes the key, d
does not have the new value that I gave d=d+1
or d=d-1
, I tried other ways but I do not find a solution.