鼠标悬停出现的小胜利的名称是什么以及如何创建它

what is the name of small win that appear by mouse over & how to create it

我想知道通常通过鼠标悬停在对象上并显示一些描述的小弹出窗口 window 的名称。例如在下图中,鼠标悬停在 google 搜索麦克风图标上时会出现:

我的下一个问题是如何通过 java 脚本创建此弹出窗口 windows。

一般

您正在查找 HTML title 属性。此属性对任何 HTML 元素都有效,如下所述:https://www.w3schools.com/tags/att_global_title.asp

在HTML

因此您可以将 title 属性添加到任何 HTML 元素。例如:

<a href="#" title="This is your tooltip content">Link</a>

我为你准备了一个jsfiddle:https://jsfiddle.net/g2106c9e/

在Javascript

您可以将 title 属性动态分配给任何元素。

// Get a DOM element
var element = document.getElementById("some-element-id")

// Set this elements title attribute
element.setAttribute("title", "This is your tooltip content")

这是另一个有效的 jsfiddle:https://jsfiddle.net/p5sLvd63/