JavaScript Basic HoverOver

By F*U*R*B*Y* on Jun 19, 2008

pretty straight forward. Get the code, save it in a filename.html then run it. Hover over one of the sites named above the horizontal line to get further information below.

This is just to help some people learn JavaScript don't really care what the rating is just there to help people :)

<html>
<head>
<script type="text/JavaScript" language="JavaScript">
function a (info) {
    switch (info) {
        case "Hawkee":
            document.getElementById("data").innerHTML = "Hawkee is a social network that focuses on social software and social shopping. Our members are active developers and consumers who share a fond interest in technology. From video games to PHP scripting we cover a variety of topics for the technically inclined. Users can share code snippets, product reviews, comments, screenshots, photos and downloads in order to gain valuable feedback from friends in their network.";
        break;
        case "XCodes":
            document.getElementById("data").innerHTML = "X-Static Codes is a website based on many different coding languages";
        break;
        case "CodeDB":
            document.getElementById("data").innerHTML = "CodeDB (Code Database) is a website based on many different coding languages";
        break;
    }
}
</script>
</head>

<body>
<b>To get more information about a site, hover over it.</b><br />
<span onmouseover='JavaScript:a("Hawkee")'>Hawkee.com</span> <b> | </b>
<span onmouseover='JavaScript:a("XCodes")'>X-Static Codes</span> <b> | </b>
<span onmouseover='JavaScript:a("CodeDB")'>CodeDb</span> <b> | </b>
<hr />
<div id="data" class="data"></div>
</body>
</html>

Comments

Sign in to comment.
Korvin   -  Mar 03, 2010

html:

<span class='mover' name="Hawkee is a social network that focuses on social software and social shopping. Our members are active developers and consumers who share a fond interest in technology. From video games to PHP scripting we cover a variety of topics for the technically inclined. Users can share code snippets, product reviews, comments, screenshots, photos and downloads in order to gain valuable feedback from friends in their network.">Hawkee.com</span> <b> | </b>
<span class='mover' name="X-Static Codes is a website based on many different coding languages">X-Static Codes</span> <b> | </b>
<span class='mover' name="CodeDB (Code Database) is a website based on many different coding languages">CodeDb</span> <b> | </b>
<hr />
<div class="data"></div>

javascript:

$('.mover').hover(function(){$('.data').text($(this).attr('name'));},function(){$('.data').text('');});

basic html:

<span class='mover' name='ROLLOVER TEXT'>Rollover me!</span><span class='data'></span>

does the same thing yours does, but with one line of javascript =] jquery ftw

 Respond  
vaseline28   -  Jul 01, 2008

I found it useful also. I adapted it for my own needs however!
Changed slightly:

<span onmouseover=\'JavaScript:a(\"Hawkee\")\' onmouseout=\'Javascript:a(\"Null\")\' >Hawkee.com
and added this to the end of the Javascript cases(before two final \'} }\' ):
case \"Null\":
document.getElementById(\"data\").innerHTML = \"\";
break;
This means that when the mouse no longer hovers over, the text vanishes!

 Respond  
Jonesy44   -  Jun 22, 2008

Surely the complexity of the snippet should not be used. For instance, if a user uses $regex instead of isin/iswm .. They should not be rated down for it. Aslong as it works. I found this snippet pretty dam helpful for my website, so i rated 7 :]

 Respond  
vaseline28   -  Jun 22, 2008

Averages \"Neat\". Personally, I know only the tiniest bit of Javascript, so a respectable effort with the script, well done!

 Respond  
Hawkee   -  Jun 22, 2008

Looks like your score is pretty high for such a simple snippet.

 Respond  
F*U*R*B*Y*   -  Jun 22, 2008

It doesn\'t really bother me, but i\'d at least to find out WHY i got such a low score....

Can you give me a reason or is it just because you can???

 Respond  
F*U*R*B*Y*   -  Jun 21, 2008

Yup, alot of people don\'t really know how to use innerHTML, i must admit, i didn\'t for a few weeks :P

 Respond  
Hawkee   -  Jun 20, 2008

Definitely important to learn getElementById and innerHTML so for that this is a useful snippet.

 Respond  
F*U*R*B*Y*   -  Jun 19, 2008

Thank you,

I started learning JavaScripting about 4 or 5 weeks ago, and decided to finally post something on JavaScript ;)

Thanks for the score, i don\'t really care about the score for this as i\'m posting this to help other people.

Furby

 Respond  
Jonesy44   -  Jun 19, 2008

Nice work, Furby.
I may use this sometime!

7/10

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.