在同一页面上多次使用 jquery 工具提示

本文关键字:jquery 工具提示 一页 | 更新日期: 2023-09-27 18:32:47

我正在 asp.net 中继器元素上使用jquery工具提示。

<div class="tooltip" style="display: none">
<div style="text-align: center; font-weight: bold;">
<%# Eval("Name") %><br />
</div>
</div>

$(function () {
    var du = 1000;
    var tooltip;
    $(document).tooltip({
        show:{effect:'slideDown'},
            items: "h5",
            content: function () {
                tooltip = $(this).siblings('.tooltip');
                return tooltip.html();
        }
    });
    });

我现在必须实现帮助功能。应该有一个帮助图标,然后单击 图标应该打开一个弹出窗口并带有说明,我想再次使用jquery工具提示。 这次我不知道如何实现它,我应该将其包含在上面的同一$function()中还是我应该使用另一个函数吗?

如果有人有任何想法,请告诉我..

在同一页面上多次使用 jquery 工具提示

按照你写它的方式,你不应该再做任何JavaScript了。任何与tooltip类具有同级的<h5>元素都将被激活。您所要做的就是在应该激活它的东西旁边放置一个.tooltipdiv。例:

<ul>
 <li>
   <h5>Here is thing 1.</h5>
   <div class="tooltip" style="display: none">This is tooltip 1.</div>
 </li>
 <li>
   <h5>Here is thing 2.</h5>
   <div class="tooltip" style="display: none">This is tooltip 2.</div>
 </li>
</ul>

如果希望工具提示适用于 h5 以外的元素,请修改items选项:

items: "h5, img.help-icon",

确保每个触发器/工具提示对都是同级,并确保每对周围都有某种类型的包装器,以显示哪个工具提示与哪个元素一起使用。例如,这将无法正常工作:

<li>
  <div>
    <h5>Here is thing 1.</h5>
  </div>
  <div class="tooltip" style="display: none">This won't show up at all!</div>
</li>

这也不会:

<li>
  <h5>Here is thing 1.</h5>
  <div class="tooltip" style="display: none">This will be the text for both tooltips!</div>
  <h5>Here is thing 2.</h5>
  <div class="tooltip" style="display: none">This won't show up at all!</div>
</li>