如何使用javascript在页面中实现工具提示? [英] How to implement tooltip in a page using javascript?

查看:60
本文介绍了如何使用javascript在页面中实现工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中有100个脚注,因此我想为这些脚注实现工具提示,即内容中提到的脚注在文档末尾有参考文献。所以我要求的是必须有一个javascript从文档的底部拉出文本,并显示为内容文档中悬停的footlink的工具提示。我有逻辑,但没有得到我应该如何实现。

要完成hove的内容段和脚注内容的段落。

I have a page which has 100's of footnotes and hence i want to implement tooltip for those footnotes i.e footnotes referred in the content has its reference para at the end of document. So I require is that there must be a javascript which pulls the text from the bottom of the document and show as a tooltip to the footlink hovered within the content document. I have just logic but not getting how should I implement.
Paragraph in content where hove is to be done and paragraph of the footnote content is to be displayed.

<p>This is the content part <sup><a name="a" href="#_a">a</a></sup></p>





底部:



Bottom part:

<p>This is the footnote part <sup><a name="_a" href="#a">a</a></sup></p>

推荐答案

你可以使用jQuery UI





You can use jQuery UI


<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Tooltip - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>


(function() {
(function() {


(document).tooltip();
});
< / script >
< style >
label {
display:inline-block;
宽度:5em;
}
< / style >
< / head >
< body >
< p > < a href = title = 这个小部件是什么 > 工具提示< ; / a > 可以附加到任何元素。当您使用鼠标将元素悬停在
时,title属性将显示在元素旁边的一个小框中,就像本机工具提示一样。< < span class =code-leadattribute> / p >
< p > 但由于它不是原生工具提示,因此可以设置样式。使用
构建的任何主题< href = http:// jqueryui。 com / themeroller / title = ThemeRoller:jQuery UI& s主题构建器应用程序 > ThemeRoller < / a >
将也相应地设置工具提示样式。< / p >
< p > 工具提示对表单元素也很有用,可以显示som每个字段上下文中的附加信息。< / p >
< p > < label = age > 您的年龄:< / label > < 输入 < span class =code-attribute> id = age title = 我们仅针对统计目的询问您的年龄。 > < / p >
< p > 将鼠标悬停在该字段上以查看工具提示。< / p >
< / body >
< / html >
( document ).tooltip(); }); </script> <style> label { display: inline-block; width: 5em; } </style> </head> <body> <p><a href="#" title="That&apos;s what this widget is">Tooltips</a> can be attached to any element. When you hover the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.</p> <p>But as it's not a native tooltip, it can be styled. Any themes built with <a href="http://jqueryui.com/themeroller/" title="ThemeRoller: jQuery UI&apos;s theme builder application">ThemeRoller</a> will also style tooltips accordingly.</p> <p>Tooltips are also useful for form elements, to show some additional information in the context of each field.</p> <p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes."></p> <p>Hover the field to see the tooltip.</p> </body> </html>


这篇关于如何使用javascript在页面中实现工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆