View Full Version : Onclick dissapear

08-19-2008, 06:10 PM
:confused:I have the following code...

<center>Shoot an "A"</center>
<div class="shoot"><span onclick="alert('Miss');">BTEHJD</span>
<span id="a" onclick="alert('Hit');">A</span>
<span onclick="alert('Miss');">GDHJD</span>
<span id="b" onclick="alert('Hit');">A</span>
<span onclick="alert('Miss');">KBFKBM<br>B</span>
<span id="c" onclick="alert('Hit');">A</span>
<span id="d" onclick="alert('Hit');">A</span>
<span id="e" onclick="alert('Hit');">A</span>
<span onclick="alert('Miss');">BGDJJVB</span>
<span id="f" onclick="alert('Hit');">A</span>
<span onclick="alert('Miss');">G</span>
<span id="g" onclick="alert('Hit');">A</span>
<span onclick="alert('Miss');">HDJNJJ<br>HDFGBJVBKJGVJG</span>
<span id="h" onclick="alert('Hit');">A</span>
<span onclick="alert('Miss');">HFGTR</span>
cursor: crosshair;
height: 75px;
width: 200px;
BORDER: solid 2px grey;}
</style>Can I make the A's Disapear Onclick:confused:

08-19-2008, 06:26 PM
just add this after your alerts on all of your 'hit's

if you want a reset you need to loop through all of the elements and set their display back to normal

08-19-2008, 09:25 PM
how do you do that?:confused:Sorry I am very New

08-19-2008, 10:29 PM
<span id="d" onclick="alert('Hit');this.display='none';">A</span>

08-20-2008, 05:06 AM
<span id="d" onclick="alert('Hit');this.display='none';">A</span>

Actually, that would be this.style.display = 'none'; rather than this.display = 'none';.


If one wanted to hide elements without affecting the surrounding layout, one would use this.style.visibility = 'hidden';.
If one had no further use for these elements, they could be removed entirely via this.parentNode.removeChild(this);.

08-20-2008, 07:35 AM
That's Perfect and I will prefer that "this.parentNode.removeChild(this);" method if it is not needed anymore.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum