The jQuery tooltip works great for the first row of data in my table. After that, I only get the old school windows default tooltip in both IE and FF.
jQuery工具提示非常适合我表中的第一行数据。之后,我只在IE和FF中获得旧学校窗口默认工具提示。
Here is the HTML that builds table data:
以下是构建表数据的HTML:
foreach ($displayData as $row) {
echo '<tr bgcolor="' . $bgcolor[$a] . '">';
echo '<td><span id="fancy" title="Course Description: - '.$row["TSTRDS"].'">'.$row["TSTRTP"].'</span></td>';
echo '<td>'.$row["TSTRLC"].'</td>';
echo '<td>'.$row["TSADDR"].'</td>';
echo '<td>'.$row["TSDATE"].'</td>';
echo '<td>'.$row["TSTIME"].'</td>';
echo '<td>'.$row["TSCOST"].'</td>';
echo '</tr>';
echo '<tr bgcolor="' . $bgcolor[$a] . '">';
echo '<td colspan="2"></td>';
echo '<td>'.$row["TSCITY"].','.$row["TSST"].' '.$row["TSZIP"].'</td>';
echo '<td colspan="3"></td>';
echo '</tr>';
$a = !$a;
}
Here is my javascript:
这是我的javascript:
$(document).ready(function(){
$('#fancy').tooltip({
track: true,
delay: 0,
showURL: false,
fixPNG: true,
showBody: " - ",
top: -15,
left: 5
});
});
And lastly, my CSS:
最后,我的CSS:
#tooltip {
position: absolute;
border: 1px solid #111;
background-color: #eee;
padding: 5px;
font-size: 14px;
width: 400px; }
Seems odd that the first row works and the rest do not. Do I need some sort of looping javascript to use the tooltip for all rows of my table? I thought that jQuery tooltip would take care of that sort of thing.
似乎很奇怪,第一行有效,其余则没有。我是否需要某种循环javascript来为我的表的所有行使用工具提示?我认为jQuery工具提示会处理那种事情。
1 个解决方案
#1
6
Instead of an ID like this:
而不是像这样的ID:
id="fancy"
You should use a class like this:
你应该使用这样的类:
class="fancy"
then bind it using a .class
selector, like this:
然后使用.class选择器绑定它,如下所示:
$('.fancy').tooltip({
IDs are supposed to be unique in a document...when you break this rule, things start to get scary :) Use a class in situations like this one.
ID应该在文档中是唯一的...当你破坏这个规则时,事情开始变得可怕:)在类似这样的情况下使用类。
#1
6
Instead of an ID like this:
而不是像这样的ID:
id="fancy"
You should use a class like this:
你应该使用这样的类:
class="fancy"
then bind it using a .class
selector, like this:
然后使用.class选择器绑定它,如下所示:
$('.fancy').tooltip({
IDs are supposed to be unique in a document...when you break this rule, things start to get scary :) Use a class in situations like this one.
ID应该在文档中是唯一的...当你破坏这个规则时,事情开始变得可怕:)在类似这样的情况下使用类。