Example: I have the tags
<a href="a1.html"> show 1 </a>
<a href="a2.html"> show 2 </a>
<a href="a3.html"> show 3 </a>
<a href="a4.html"> show 4 </a>
When I place cursor on show2, the tooltip would show content of a2.htmlThanks.
Bruce
<a href="a1.html"> show 1 </a>
<a href="a2.html"> show 2 </a>
<a href="a3.html"> show 3 </a>
<a href="a4.html"> show 4 </a>
When I place cursor on show2, the tooltip would show content of a2.html
<a href="a1.html" class="dynTooltip">show 1 </a>
$(document).ready(function() {
$(".dynTooltip").tooltip({
effect: 'slide',
tip:'#theTooltip',
onBeforeShow: function(){
theUrl = this.getTrigger().attr("href");
getAjaxData(theUrl, this.getTip());
}
});
function getAjaxData(theUrl, $tip) {
$tip.text('loading...');
$.ajax({
url:theUrl,
success: function(response) {
$tip.text(response);
}
});
}
});
function getAjaxData(theUrl, $tip) {
$tip.text('loading...');
$.ajax({
url:theUrl,
success: function(response) {
$tip.html(response);
}
});
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.jquerytools.org/1.2.5/all/jquery.tools.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#demo span[title]").tooltip({effect: 'slide'});
$(".dynTooltip").tooltip({
effect: 'slide',
tip:'#theTooltip',
onBeforeShow: function(){
theUrl = this.getTrigger().attr("href");
getAjaxData(theUrl, this.getTip());
}
});
function getAjaxData(theUrl, $tip) {
$tip.text('loading...');
$.ajax({
url:theUrl,
success: function(response) {
$tip.text(response);
}
});
}
});
</script>
</head>
<body>
<div id="demo" style="position: absolute; left: 100px; top: 100px;">
<span title="The tooltip text #1">Hover over this text and it works</span>
</div>
<div style="position: absolute; left: 200px; top: 150px;">
<a href="/test.html" class="dynTooltip">Hover over this text and it does not work</a>
</div>
</body>
</html>
onBeforeShow: function(){
if (this.getTrigger().attr('title') != '') {
this.getTip().text( this.getTrigger().attr('title') );
}
}
$('input[name=XXX]').attr('title','Blablablabla.');