javascript - Trying to display image in a game of memory -



javascript - Trying to display image in a game of memory -

okay, problem. i'm creating game of memory images in it. cannot understand how able display image after setting display='none' for-loop onload function.

i've tried couple of hours without result. =(

anyone can help me?

and elem.id points td id it's dynamic. it's tricky because in every td there img.

i sincerely appreciate help.

this code:

var clicked = true; var firstclick; var secondclick; var firstplayer = true; var addpointplayer1 = 0; var addpointplayer2 = 0; var totalpoints = 8; function clickcard(elem){ //document.getelementsbytagname('img').style.display = ""; if(clicked){ firstclick = document.getelementbyid(elem.id); // document.getelementsbyname(/.img/).style.visibility="visible"; firstclick.style.backgroundcolor= "white"; clicked = false; } else{ secondclick = document.getelementbyid(elem.id); secondclick.style.backgroundcolor = "white"; if(firstclick.innerhtml == secondclick.innerhtml){ firstclick.style.backgroundcolor="white"; secondclick.style.backgroundcolor="white"; if(firstplayer){ addpointplayer1++; totalpoints--; } else{ addpointplayer2++; totalpoints--; } } else { alert('this not pair, player change'); firstclick.style.backgroundcolor="#7f1a1a"; secondclick.style.backgroundcolor="#7f1a1a"; if(firstplayer){ firstplayer = false; } else{ firstplayer = true; } } clicked = true; } //keeping command of winner if(totalpoints == 0){ if(addpointplayer1 > addpointplayer2){ alert("game over! player 1 wins " + addpointplayer1 + " points" + addpointplayer2); } else if (addpointplayer1 == addpointplayer2){ alert("this draw press cmd+r rematch"); } else{ alert("game over! player 2 wins " + addpointplayer2 + " points against " + addpointplayer1); } } } //creates blank game-plan function hidegameplan(){ var images = document.getelementsbytagname('img'); (i = 0; < images.length;i++ ) { images[i].style.display = "none"; } }

if you've set display none, somewhere else should setting display - ie block.

i recommend help: http://www.w3schools.com/cssref/pr_class_display.asp

javascript html css dom

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -