大家好,我正在尝试为每个 HTML 表格单元格
创建工具提示,你们知道如何在此处获取 td
属性 id
非常感谢 jquery 代码示例
$(function () {
$(".test").hover(
function () {
var toolTipHtml = $("#ToolTipDiv").clone();
$(this).append(toolTipHtml);
toolTipHtml.show("slow");
},
function () {
var toolTipHtml = $(this).find(".tooltip");
toolTipHtml.hide();
toolTipHtml.remove();
}
);
});
echo "<table>";
while($row = mysql_fetch_array($result))
{
$id = $row['id_out_org'];
echo "<tr>";
echo "<td>" .$row['KG']."</td>";
echo "<td class='test'>" .$row['B']."</td>";
echo "<td >" .$row['B']."</td>";
echo "<td class='test'>";
echo "<div id = 'ToolTipDiv' class='tooltip' style='background-color: White; display: none; width: 20%;'>";
echo "Total: $ "; echo $totalp = $total + $fuel;
echo "</div>";
"</td>";
echo "</tr>";
}
echo "</table>";
最佳答案
使用包罗万象的选择器,然后迭代它们:
$("td[id$=ToolTipDiv_]").each(function() {
$(this).attr('title', 'some tool tip');
});
关于php - 如何使用jquery获取html表td属性唯一id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11008144/