0

こんにちはみんな私はすべてのツールチップを作成しようとしてHTML table cellいますあなたたちは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>";
4

4 に答える 4

1

キャッチオール セレクターを使用してから、それらを反復処理します。

$("td[id$=ToolTipDiv_]").each(function() {
    $(this).attr('title', 'some tool tip');
});
于 2012-06-13T04:21:20.847 に答える
1

ツールチップでこのオープンソースプラグインを使用することをお勧めします

あなたのニーズを満たすかもしれません。ここで例を参照してください

$('#table td.test').tooltip();
于 2012-06-13T04:42:42.680 に答える
0

すべてのテーブル セルから HTML と ID を取得するには:

$('td').each(function() {
  var toolTipHtml = $(this).html(); // now you have the contents of the cell
  id = $(this).attr('id');  // now you have the id
});
于 2012-06-13T04:24:39.247 に答える
0

フーバーを使用しているので、このようなものを使用できます

$('.tooltip').hover(function() {
   alert(this.id);
   // or to get the id of the row
var toolTipHtml = $("#"+this.id).clone();
});
于 2012-06-13T04:32:36.363 に答える