javascript - 如何为 HTML 中表格的 <th> 元素提供工具提示

标签 javascript jquery html css

如何在悬停元素时向表格元素提供工具提示。

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

将鼠标悬停在元素上时,工具提示应为“等级描述”

最佳答案

只需设置title属性

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

如果你想动态设置

$('#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>

关于javascript - 如何为 HTML 中表格的 <th> 元素提供工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39137799/

相关文章:

javascript - 如何使用intersectionObserver/Scrollspy在元素上显示特定类?

javascript - 选择选项时选择元素上的 jQuery 事件(不是 .change)

iphone - 背景大小 : cover looks pixelated on retina display

javascript - 将 Django 模板变量传递到 GAE 中的 javascript

javascript - Node.js/REST : How to get _id from url

javascript - 如何阻止我的模式添加新行?

javascript - 在 jquery mobile 中离开页面时结束 SetInterval 函数

javascript - 如何使用 CSS3 过渡

html - css-grid 以行而不是列呈现 div

HTML & CSS : How I can make an image's bottom edge align with text?