tags:

views:

30

answers:

5

i am playing with the onmouseover event in javascript

i would like a little box to pop up and remain up until there is no onmouseover anymore

i think it's called a decription box, but i am not sure?

how do i get a little box to pop up with custom text when i put my mouse over certain text>? and i need it to disappear once i move the mouse to a different object

+1  A: 

I'd try doing this with jQuery's .hover() event handler system, it makes it easy to show a div with the tooltip when the mouse is over the text, and hide it once it's gone.

Here's a simple example.

HTML:

​<p id="testText">Some Text</p>
<div id="tooltip">Tooltip Hint Text</div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Basic CSS:

​#​tooltip {
display:none;
border:1px solid #F00;
width:150px;
}​

jQuery:

$("#testText").hover(
   function(e){
       $("#tooltip").show();
   },
   function(e){
       $("#tooltip").hide();
  });​​​​​​​​​​
Trafalmadorian
+1  A: 

They called tooltips. If you are using jQuery this following link has a list of useful jQuery Tooltip Plugins.

http://www.1stwebdesigner.com/resources/stylish-jquery-tooltip-plugins-webdesign/

jairajs89
A: 

If you can use a jQuery plugin this is an easy to use and effective one:

http://jquery.bassistance.de/tooltip/

Eton B.
+1  A: 

Assuming popup is the ID of your "description box":

HTML

<div id="parent">
This is the main container.
<div id="popup" style="display: none">some text here</div>
</div>

JavaScript

var e = document.getElementById('parent');
e.onmouseover = function() {
  document.getElementById('popup').style.display = 'block';
}
e.onmouseout = function() {
  document.getElementById('popup').style.display = 'none';
}

Alternatively you can get rid of JavaScript entirely and do it just with CSS:

CSS

.parent .popup {
  display: none;
}

.parent:hover .popup {
  display: block;
}
casablanca
+1  A: 

Well, I made a simple two liner script for this, Its small and does what u want.

Check it http://jsfiddle.net/9RxLM/

Its a jquery solution :D

Starx