I want to pass this as a parameter for a function in javascript , as see below :
<input type="image" class="img_btn" id="img" src="img1.jpg" onclick="edit(this);"/>
and my edit function :
function edit(javad) {
if (x == 1) {
javad.src = "img1.jpg";
x = 0;
} else {
javad.src = "img2.jpg";
x = 1;
}
}
and default value for x is 1.
But it does not work ?
Thanks for your help.
I solve problem 🙂
it does not works true because of var x is global, and in per call function it set to 1.Thanks.