简体   繁体   English

如何给工具提示 <th> HTML中表格的元素

[英]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" 悬停元素时,工具提示应为“成绩描述”

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

jQuery的另一个选择是

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

Just set the title attribute 只需设置title属性

 <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> 

您可以使用jQuery设置title属性。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM