2011-02-14 4 views
32

tabletd을 올릴 때마다 툴팁을 추가하는 예를 들려 줄 수 있습니까?테이블의 td에 툴팁을 추가하는 방법

툴팁 내용은 데이터베이스 레코드에서 가져와야합니다.

예 : 나는 테이블에 이름을 가져 가면

가 .. 툴팁이 그/그녀의 정보를 표시해야합니다.

+4

@ Shaz의 대답에서 알 수 있듯이 jQuery (질문에 태그를 추가 했음)는 필요하지 않습니다. 'title' 엘리먼트 속성은 그 일을 잘 처리해야합니다. 툴팁에서 더 많은 기능을 필요로하지 않는다면? 데이터베이스 액세스에 대해서는 모든 서버 측에서 수행되지만 일반적으로이 설정에서 데이터베이스 액세스를 수행합니다. – David

답변

4
<?php 
    $test = "Test" 
?> 


<table> 
    <tr> 
     <td title="<?php echo $test; ?>">Hi there</td> 
    </tr> 
</table> 
+3

에코를 잊어 버리셨습니까? –

32

사용에게 title 속성 :

<table> 
    <tr> 
     <td> 
      <a href="#" title="John Smith lives in New York."> John Smith </a> 
     </td> 
    </tr> 
</table> 

라이브 데모 : 당신이 추가하면 당신은 호버에 툴팁을 얻을 것이다http://jsfiddle.net/GpU5f/

27

을 '제목 = "뭐든간에 " '에 <td> :

제목의 내용이 다른 아마도 더 어려운 이야기에서 유래하지만, 아마도 당신은 셀의 동일한 작업을 수행 할 세포의 innerText와를 제공하는 프로그램 코드를 정렬 할 수 있습니다
<tr><td title="whatever">hover here to see "whatever" in a tooltip</td> 

title=....

HTH

- 원래의 질문이 예 JQuery와 및 없음 태그 이후 피트

2

언급, 그것은

$(tdSelector).attr('title', titleText);

0

의 문제가에서의이 (그러나 사소한) angular.js 다음과 같이 작동 할 수 있습니다. -

<table> 
<tr ng-repeat="data in list"> 
<td class="table-text-right tooltip-enable-mandatory" data-toggle="tooltip" data-container="#tableRoceMovement"data-original-title="{{data.value}}" title="{{data.value}}"data-placement="bottom" data-html="true" onmouseenter="tooltipEnterEvent($(this))" onmouseleave="tooltipLeaveEvent($(this))">{{data.value}}</td> 
</tr> 
</table> 
관련 문제