gpt4 book ai didi

php - 如何使用jquery获取html表td属性唯一id

转载 作者:行者123 更新时间:2023-11-29 08:51:43 25 4
gpt4 key购买 nike

大家好,我正在尝试为每个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com