<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample of vTip by inTechgrity ~ Swashata</title>
<style>
body { padding: 40px;
margin: 20px;
font-size: 14px;
font-face: Verdana;
}
.mydiv{ /* Keep hidden until called by javascript */
display:none;
Border:silver 2px solid;
width:500px;
/* some space for BG image */
padding:2px 2px 2px 100px;
background: #81a8b8 url(http://i28.tinypic.com/10erm2b.gif) no-repeat left center;
font-size:25px;
color:#333333;
margin:5px;
}
p#vtip { display: none;
position: absolute;
padding: 10px;
left: 5px;
font-size: 13px;
font-weight: bold;
font-family: Arial;
background: transparent url(http://i28.tinypic.com/zswn6g.png) scroll repeat 0 0;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
z-index: 9999;
max-width: 150px;
}
p#vtip #vtipArrow { position: absolute;
top: -11px;
left: 10px
}
</style>
<!-- first load jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<!-- Now we are including the JS library of vTip plugin directly, You can use any mehtod you want! -->
<script type="text/javascript">
/**
Vertigo Tip by www.vertigo-project.com
Requires jQuery
*/
this.vtip=function(){this.xOffset=-10;this.yOffset=20;$(".vtip").unbind().hover(function(a){this.t=this.title;this.title="";this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);$("body").append('<p id="vtip"><img id="vtipArrow" />'+this.t+"</p>");$("p#vtip #vtipArrow").attr("src","http://i26.tinypic.com/5b8ck3.png");$("p#vtip").css("top",this.top+"px").css("left",this.left+"px").fadeIn("slow")},function(){this.title=this.t;$("p#vtip").fadeOut("slow").remove()}).mousemove(function(a){this.top=(a.pageY+yOffset);this.left=(a.pageX+xOffset);$("p#vtip").css("top",this.top+"px").css("left",this.left+"px")})};jQuery(document).ready(function(a){vtip()}); </script>
<!-- And some more effect for the div animation! Not needed, but still lets see what jQuery can do actually ;) -->
<script type="text/javascript">
$(document).ready(function() { $("div.mydiv").show(5000);
$("#anchor").click(function() { //get the element having id "anchor" Again we could have used a#anchor but I like my code to be short, Now the following onClick events are introduced $("div.mydiv").toggle(1000); //Toggles the display and visibility. To know more about toggle see here http://docs.jquery.com/Effects/toggle var valuee = $(this).html(); //We want to change the value of the <a> element when clicked. So we are getting the values using html() See here for more info http://docs.jquery.com/Attributes/html
if(valuee=="I am an anchor link! Click me!") { valuee = "Click me again to show up the div below"; } // This and below line conditionally sets the value else { valuee = "I am an anchor link! Click me!"; } $(this).html(valuee); //Now we ultimately change the innerHTML to our modified value
return false; //Again to make sure that href is not followed
});
});
</script>
</head>
<body>
<a class="vtip" id="anchor" title="Hi! How are you.. This is the Tooltip which will be shown when the document is ready" href="http://www.intechgrity.com">I am an anchor link! Click me!</a>
<div style="clear: both;"> </div>
<div class="vtip mydiv" title="You can also show the tooltip for a div or any html element">Hover on me! I am a div element having two classes... Bascially it is all the same. We are just using the default class system. The Plugin is designed in such a way that it will bind the function to every HTML element having class vTip and will show the tooltip having the title of the same element. You can check the uncompressed version of the vTip js to see how things are programmed</div>
<img src="http://1.bp.blogspot.com/_M0X9MzkzNXE/Sl7QpE_M8zI/AAAAAAAADfM/NvY7dTGMv3s/S1600-R/logo-ITG.jpg" title="Obviously it can also be applied over an image" class="vtip"/>
</body>
</html>