每个 qTip 工具提示的自定义内容
我有一个搜索结果列表,对于每个搜索结果,我希望能够在工具提示中显示有关相关结果的更多信息。
当我滚动每个 a 元素时,我已经得到了一个 qTip 工具提示,但我不明白如何将自定义内容添加到每个结果的工具提示中。
我想这主要是因为我的 jQuery 知识非常有限。
在旧式 JavaScript 中,我会传递一个变量,该变量是附加到 标记的函数调用中的工具提示内容。由于 jQuery 工具提示的
标记中没有编写函数调用,因此看起来现在不是这样做的方法。
目前我的头部有这个:
<script type="text/javascript"
src="/assets/templates/unaexchange/js/jquery.qtip-1.0.0.min.js"></script>
<script>
$(document).ready(function() {
$(".tooltip").qtip({
content: 'this is the content',
position: {
corner: {
target: 'topRight',
tooltip: 'bottomLeft'
}
}
});
});
然后主体有 Link
然后我有标准:
<div class="qtip qtip-stylename">
<div class="qtip-tip" rel="cornerValue"></div>
<div class="qtip-wrapper">
<div class="qtip-borderTop"></div>
<!-- Only present when using rounded corners-->
<div class="qtip-contentWrapper">
<div class="qtip-title">
<!-- All CSS styles...-->
<div class="qtip-button"></div>
<!-- ...are usually applied...-->
</div>
<div class="qtip-content">an attempt at standard content ?></div>
<!-- ...to these three elements!-->
</div>
<div class="qtip-borderBottom"></div>
<!-- Only present when using rounded corners-->
</div>
</div>
但这没有被显示并且我不知道如何为每个工具提示创建特定的 HTML 块。
我的做法有错吗?
我是否应该创建包含具有单独 ID 的自定义内容的所有单独工具提示,然后选择这些 ID 并显示或类似的内容?
I have a list of search results and for each one I want to be able to display more information about the result in question in a tooltip.
I have got as far as getting a qTip tooltip to appear when I rollover each a element but I don't understand how to get custom content into the tooltip for each result.
I guess this is largely because of my very limited jQuery knowledge.
In old style JavaScript I would pass a variable that was the tooltip content from the function call attached to the <a>
tags. As there is no function call written in the <a>
tag for jQuery tooltip it looks like this isn't the way to do it now.
Currently I have this in the head:
<script type="text/javascript"
src="/assets/templates/unaexchange/js/jquery.qtip-1.0.0.min.js"></script>
<script>
$(document).ready(function() {
$(".tooltip").qtip({
content: 'this is the content',
position: {
corner: {
target: 'topRight',
tooltip: 'bottomLeft'
}
}
});
});
And then the body has <a class="tooltip">Link</a>
and then I have the standard :
<div class="qtip qtip-stylename">
<div class="qtip-tip" rel="cornerValue"></div>
<div class="qtip-wrapper">
<div class="qtip-borderTop"></div>
<!-- Only present when using rounded corners-->
<div class="qtip-contentWrapper">
<div class="qtip-title">
<!-- All CSS styles...-->
<div class="qtip-button"></div>
<!-- ...are usually applied...-->
</div>
<div class="qtip-content">an attempt at standard content ?></div>
<!-- ...to these three elements!-->
</div>
<div class="qtip-borderBottom"></div>
<!-- Only present when using rounded corners-->
</div>
</div>
But this isn't being displayed and I don't know how to create a specific chunk of HTML for each tooltip.
Is my approach wrong?
Should I create all the individual tooltips containing the custom content with separate IDs and then pick these IDs up and display or something like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用所需的工具提示内容向每个 DOM 元素添加
title
属性。例如,无论您的标记是什么
或
某些链接
title
属性为 所有 DOM 元素的 HTML 5 标准。Add a
title
attribute to each DOM element with the tooltip content that you want. E.g.,<span class='tooltip' title='This will show up as a tooltip'>Whatever your markup happens to be</span>
or
<a class='tooltip' href='#' title='Another tooltip'>Some link</a>
The
title
attribute is standard in HTML 5 for all DOM elements.您可以省略 content 属性以使用
标记的标题:
或者您可以使用 jquery 选择器。例如:
示例在这里:jsFiddle
you can omit the content property to use the title of the
<a>
tag:or you can use a jquery selector. for example:
Example here: jsFiddle