A simple Tooltip using javascript.

A “tooltip” is one name given to the small yellow box that appears when you hover over an object on your screen when ‘title’ attribute is use for that particular object.This box simply appears whenever ‘title’ attirbute is use for the particular html element. For eg. Hover Here . When we hover on  this link we can see yellow box written ‘tooltip’.This is the defulat tooltip provided by the browser itself.

Now a days tool tip are  widely used  in many customized forms using javascript avoiding the default yellow box that browser provides.It is basically used to display the short contents for the particular objects in more attractive way and to enhance the users experience. I tried to make simple javascript tooltip which works in every DOM element which has class named as ‘tooltip’ i.e ‘<a>’,’ <div>’,'<span>’ etc .It simply catches the mousemove event and its respective x and y coordinates with respect to browser window.It is tested in the Firefox and IE.Furthermore, it can be easily customized as the codes  are well commented.

DEMO

How to use:

Eg.....<script src='tooltip.js'></script></head>
Eg <a href="#" class='tooltip' title='I want be displayed on tooltip''>Tooltip</a>

DEMO  
Download Link (JS file ) :tooltip.js
Download Link (Image file ) :Tool Tip Image

Note: By default image file is on the same directory that of js file. If you want to change the image path then find the ‘url’ on the js file and change the image path next to css ‘url’.

754 views
Javascript

Comments

7 Responses to “A simple Tooltip using javascript.”

Leave Comment

(required)

(required)