Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Javascript: show/hide contents os <span>

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Barrucadu

Established Member
Impact
64
I am attempting to show a <span> tag when the user hovers over a link, and hide it when they move the mouse off. But the code just dosn't work.

Here is my JavaScript:
Code:
function showSpan(name){
     document.getElementByName(name).style.display = "block";
}
function hideSpan(name){
     document.getElementByName(name).style.display = "none";
}

Here is my HTML:
Code:
<a href="Algorithms.html" onMouseOver="showSpan('Algorithms');" onMouseOut="hideSpan('Algorithms');">Algorithms</a>
<span name="Algorithms" style="display:none;"> - Test.</span>
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
1. in your span, replace name= with id=

2. in your function, replace both instances of getElementByName with getElementById

That should do it :)
 
1
Close
Yes.. and not so important but make onMouseOver and onMouseOut to lowercase if you want them to validate as XHTML.
 
1
Close
Ahhh, thats it. works perfectly, thanks.

PHP:
$cef->rep++;
$tm->rep++;

:)
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back