You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Imitating browsers default tooltip


Tooltips demo 3 / 7 : Imitating browsers default tooltip

The first two images show the browser's default tooltip and the last two show the jQuery Tools tooltip. We are trying to mimic the standard browser behaviour.

 

So what is the point of all this? First of all we have a similar syntax for enabling both of the tips. Browsers without JavaScript enabled will always see the default tooltip. Secondly, the browser's tooltip is not always the best one. Here are the main benefits of the jQuery Tools tooltip which cannot be achieved with the browser's default tooltip:

HTML / CSS coding

Our HTML structure is identical to the basic setup. Here we have a single tooltip element and here is how it has been styled:

.tooltip {
	display:none;
	background-color:#ffa;
	border:1px solid #cc9;
	padding:3px;
	font-size:13px;
	-moz-box-shadow: 2px 2px 11px #666;
	-webkit-box-shadow: 2px 2px 11px #666;
}

Note that we are using a drop shadow for the latest browsers, i.e. the latest versions of Firefox, Safari, Konqueror and Chrome.

JavaScript coding

A single JavaScript call initializes the tooltip. The configuration options are commented:

$("img[title]:gt(1)").tooltip({

		// use div.tooltip as our tooltip
		tip: '.tooltip',

		// use fade effect instead of the default
		effect: 'fade',

		// make fadeOutSpeed similar to browser's default
		fadeOutSpeed: 100,

		// the time before tooltip is shown
		predelay: 400,

		// tweak the position
		position: "bottom right",		
		offset: [-50, -80]
	});

Enclosing your call inside $(document).ready executes the script right after the document is scriptable. Read more about that in the User's Manual.


Here is the standalone version of this demo. You can freely study and copy its source code.