Nimmi
Nimmi

Reputation: 690

How to give tooltip to <th> element of table in HTML

How to give tooltip to element of table while hover the element.

<th id="metricsHead">Grade_Desc</th>

While hovering the element the tooltip should be "Grade Description"

Upvotes: 2

Views: 7255

Answers (3)

Lalji Dhameliya
Lalji Dhameliya

Reputation: 1769

document.getElementById('metricsHead').title = 'your new title';

other option from jquery is

$('#metricsHead').prop('title', 'your new title');

Upvotes: 2

Satpal
Satpal

Reputation: 133403

Just set the title attribute

<table>
  <th id="metricsHead" title="Grade Description">Grade_Desc</th>
</table>

if you want to set it dynamically

$('#metricsHead').attr('title', "Grade Description")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <th id="metricsHead" >Grade_Desc</th>
</table>

Upvotes: 2

User42
User42

Reputation: 965

You can set the title attribute with jQuery.

$("#metricsHead").attr("title", "Grade Description");

Upvotes: 0

Related Questions