创建 HTML、鼠标悬停在工具提示上的最简单方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7503183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:43:02  来源:igfitidea点击:

What is the easiest way to create an HTML, mouse over tool tip?

htmltooltip

提问by stackoverflow

What is the easiest, cleanest way to create an HTML, mouse over tool tip without using tons of extra js references?

在不使用大量额外 js 引用的情况下,创建 HTML、鼠标悬停在工具提示上的最简单、最简洁的方法是什么?

<img id=Pennstate src="/blah" style="cursor:pointer;">

mouse over that and have a a nice tooltip "We are Pennstate!"

将鼠标悬停在其上并显示一个不错的工具提示“我们是宾夕法尼亚州!”

回答by Samich

The easiest way is to use the native HTML titleattribute:

最简单的方法是使用原生HTMLtitle属性

<img src="https://stackoverflow.com/favicon.ico"
     style="cursor:pointer;"
     title="Stack Overflow">

But if you need more, try the tooltipwidget provided by jQuery UI since version 1.9.

但如果您需要更多,请尝试使用jQuery UI 自 1.9 版以来提供的工具提示小部件。

回答by Jaime Garcia

If you don't care much what the tooltip looks like you can always just use the "title" attribute

如果您不太关心工具提示的外观,您可以随时使用“title”属性