如何在td上修改我的工具提示

       $(document).ready(function(){ var temp= // i need this to fetch the id of which td i hovered, id of the user not id //of the td so that i can put the id in the data which will be passed to description-//hover.php $("#box-table-a span").qtip({ content: { url: 'description-hover.php', data: { id: //this should be temp here }, method: 'post' }, show: 'mouseover', hide: 'mouseout' }); });    
<?php $q=mysql_query("select * from property"); while( $f=mysql_fetch_array($q, MYSQL_ASSOC)) { $p_id=$f["p_id"]; echo" "; } ?>
B-House/Dorm Name Address Price Range Date Added Status
".$f['p_name']." ".$f['address']." ".$f['p_name']." ".$f['payment_type']." ".$status."

您可以使用其中一个内置的jQuery工具提示插件。 http://flowplayer.org/tools/tooltip/index.html

以下是将其与表格一起使用的示例: http : //flowplayer.org/tools/demos/tooltip/table.html

 $(document).ready(function(){ $("#my-table td").hover(function() { $("#property-hover").html("

Put some loading text here while the ajax call loads

"); var prop = 0; //TODO: this variable needs to be retrieved from somewhere $.ajax({ type: "POST", url: "description-hover.php", data: {id:prop}, success: function(data) { $("#property-hover").html(data); } }); }); $("#my-table td").tooltip({tip: '#property-hover'}); });

我相信你遇到的问题是你正在使用onmouseover方法做一些Tooltip允许你作为事件做的事情。 你真的不应该使用onmouseover或onclick。 相反,工具提示function具有在事件显示之前处理事件的选项。

在这种情况下,我会使用onBeforeShow事件通过ajax加载工具提示。

这是一个如何使用onBeforeShow的简单示例:

 Michael function load_user_info(event){ //functionality to ajaxy load info here } $('td.user_name').tooltip({ ... onBeforeShow: load_user_info, ... }); 

我开始在这里创建一个解决方案: http : //jsfiddle.net/mimercha/r7Hxf/23/并且没时间了。 稍后会尝试完成解决方案。

建议使用以下命令创建工具提示。 这将允许您将静态或ajax加载的内容包含到工具提示中 – jQuery qTip