...

View Full Version : Onclick dissapear



uncrocks
08-19-2008, 07: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>
</div>
<style>.shoot{
cursor: crosshair;
height: 75px;
width: 200px;
BORDER: solid 2px grey;}
</style>Can I make the A's Disapear Onclick:confused:

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

this.display='none'
if you want a reset you need to loop through all of the elements and set their display back to normal

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

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

Arbitrator
08-20-2008, 06: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';.

Additionally:

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);.

SSJ
08-20-2008, 08: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