开发者

Load different tooltip content for each link

I use this tooltip script on my site: http://craigsworks.com/projects/simpletip/

The problem is that I have several links in the same div class and I want to load different content in tooltip when the mouse is over different links. This is the code I use to load tooltip:

$(document).ready(function(){
// Create your tooltips 
var api = $(".ttip a").simpletip().simpletip(); 
api.load('include.php'); 
});

It would be great if I could send some post parameters in include.php file, based on the link that is actually hovered.

<div class="ttip">
<a userid="1" href="#" >user1</a><br />
<a userid="2" href="#">user2</a>
</div>

I need to catch the user id in include.php file in order to return appropriate information.

开发者_运维百科Now the tooltip works only for the first link. For the second one some default text is shown instead when I hover it!

Can anyone please help?


You'll have to assign the tooltips to each element separate and pass the userid using the 2nd parameter of load():

$(document).ready(function(){
 $(".ttip a")
  .each(
  function(i)
  { 
    var api=$(this).simpletip().simpletip(); 
    api.load('include.php',{userid:$(this).attr('userid')}); 
  })
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜