I working on image toggling, first click should hide the image and second click should display the image again. I got some thing working, but the issue is, on first click it is doing nothing and on second click toggling gets started. Hope there is some thing wrong in my code. Please advise.
<img src="img/1.jpg" width="449" height="600" class="one" id="one" style="opacity=1">
<img src="img/2.jpg" width="450" height="600" class="two">
function toggle(obj) {
var el = document.getElementById("one");
if ( el.style.opacity != 0 ) {
el.style.opacity = 0;
}
else {
el.style.opacity = 1;
}
}
one.addEventListener("click", toggle, false);