Unstoppable Domains

Javascript: show/hide contents os <span>

Spaceship Spaceship
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
1. in your span, replace name= with id=

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

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

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

:)
 
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back