Simple Tooltip using jQuery

There are bunch of jQuery/JavaScript Tooltip plugins available on Internet, but most of them are heavy, and since generally our requirement is not that much, they become unfavorable to use. Thus, I wrote a small and simple code snippet for Tooltips which can be achieved via jQuery, it is easy to implement and use. CSS3 Tabs with CSS3 Navigation Menu
Live Demo
// Download

The Code

The JavaScript

Unlike other plugins for this same functionality, the JavaScript/jQuery code here is really small(and assumes that you have already included the jQuery library).

$(document).ready(function() {
    $('.simpleTooltip').hover(function() {
        var title = $(this).attr('title');
        $(this).data('tipText', title).removeAttr('title');
        $('<p class="tooltip"></p>').text(title).appendTo('body').fadeIn('slow');
    }, function() {
        $(this).attr('title', $(this).data('tipText'));
    }).mousemove(function(e) {
        var mousex = e.pageX + 20;
        var mousey = e.pageY + 20;
            top: mousey,
            left: mousex


This is the CSS for the actual tooltip, I have added some additional styling properties like circular borders, opacity and box shadow, though they are completely optional. If you encounter problems with width of the tooltip, you might try fixing the width of the tooltip rather than auto.

.tooltip {
    display: none;
    position: absolute;
    opacity: 0.80;
    width: auto;
    background-color: #000;
    padding: 10px;
    color: #fff;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    -moz-box-shadow: 0 0 3px 3px #959595;
    -webkit-box-shadow: 0 0 3px 3px #959595;
    box-shadow: 0 0 3px 3px #959595;


The HTML again is very simple, just add the class simpleTooltip to any anchor link, and it’s title becomes the tooltip.

<a href="#" title="Text to be displayed in Tooltip" class="simpleTooltip">Hover for Tooltip</a>