jquery - 基础工具提示不起作用;而是显示默认浏览器工具提示

标签 jquery html tooltip zurb-foundation

我正在使用最新版本的 Foundation,并尝试在我的网站上实现他们的工具提示功能。我直接从 their webpage on Tooltips 复制并粘贴了他们的示例但这不起作用。我已链接到他们在同一网页上指示的所有文件,并且在控制台中没有收到任何错误。出现的唯一工具提示是浏览器默认设置(在 Chrome、Firefox 和 Safari 中测试)。基金会的工具提示在他们的网站上运行良好——我在我的网站上做错了什么?如果您需要查看我的 CSS 或更多 HTML 内容,请告诉我 - 我尽力使其尽可能简短。

$(document).ready(function() {
  $("div.info div.troubleshoot").mouseenter(function() {
    $("div.icon.troubleshoot").addClass("tada animated");
  });
  $("div.info div.troubleshoot").mouseleave(function() {
    $("div.icon.troubleshoot").removeClass("tada animated");
  });
})
$(document).ready(function() {
  $("div.info div.security").mouseenter(function() {
    $("div.icon.security").addClass("tada animated");
  });
  $("div.info div.security").mouseleave(function() {
    $("div.icon.security").removeClass("tada animated");
  });
})
$(document).ready(function() {
  $("div.info div.maintenance").mouseenter(function() {
    $("div.icon.maintenance").addClass("tada animated");
  });
  $("div.info div.maintenance").mouseleave(function() {
    $("div.icon.maintenance").removeClass("tada animated");
  });
})

$(document).ready(function() {
  $(window).scroll(function() {
    var y = $(window).scrollTop();
    var splashHeight = $("div.one").height();
    var fade = splashHeight - 50
    if (y > fade) {
      $("nav").css("opacity", '0.95');
    } else {
      $("nav").css("opacity", '0.75');
    };
  });
})
<html>

<head>
  <title>DragonTech &mdash; Home</title>

  <link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/css/foundation.min.css" rel="stylesheet" type="text/css" />
  <link href="css/animate.css" rel="stylesheet" type="text/css" />
  <link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/css/normalize.min.css" rel="stylesheet" type="text/css" />
  <link href="css/app.css" rel="stylesheet" type="text/css" />
</head>

<body>
  <nav>
    <ul>
      <li><a href="#top">Top</a>
      </li>
      <li><a href="#services">Services</a>
      </li>
      <li><a href="#price">Prices</a>
      </li>
      <li><a href="#">Appointment</a>
      </li>
    </ul>
  </nav>
  <div class="content" id="price">
    <h2>Our rates are affordable, understandable, and satisfaction-guaranteed.</h2>
    <div class="row">
      <div class="small-10 small-centered large-12 columns">
        <table>
          <thead>
            <tr>
              <th scope="column">Service</th>
              <th scope="column">Pricing</th>
            </tr>
          </thead>
          <tr>
            <td>General maintenance</td>
            <td>$10 per tune-up</td>
          </tr>
          <tr>
            <td>Troubleshooting</td>
            <td>$15 per hour</td>
          </tr>
          <tr>
            <td>Security assurance</td>
            <td><span data-tooltip aria-haspopup="true" class="has-tip" title="If security issues are identified, you may be charged slightly extra to compensate for the time spent restoring the computer.">$10 per session</span>
            </td>
          </tr>
          <tr>
            <td>Data recovery</td>
            <td>$20 per hour or $5 per file, whichever is cheaper</td>
          </tr>
          <tr>
            <td>Upgrade or app consultation</td>
            <td>$10 per hour</td>
          </tr>
        </table>
      </div>
    </div>
  </div>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/js/vendor/jquery.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/js/foundation/foundation.min.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/js/vendor/modernizr.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.0/js/foundation/foundation.tooltip.min.js" type="text/javascript"></script>
  <script src="js/app.js" type="text/javascript"></script>
</body>

</html>

最佳答案

你还没有initialized Foundation's JavaScript - 在脚本的顶部或底部添加以下内容:

$(document).foundation();

CodePen link

关于jquery - 基础工具提示不起作用;而是显示默认浏览器工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28261262/

相关文章:

javascript - 在多个选择下拉列表中,选定的下拉列表值(选项)需要隐藏在剩余的下拉列表中

javascript - 关闭一个弹出窗口并重新加载另一个弹出窗口

html如何相对路径

c# - 使多个控件使用相同的工具提示消息(c# 客户端应用程序)

WPF 工具提示 ControlTemplate 不显示内容

javascript - 将鼠标悬停在图像上以显示按钮,并且在悬停在实际按钮上时不会触发

php - 如何在 javascript 中使用 $.get 从 php 文件中提取两个变量

javascript - Bootstrap 导航栏下拉菜单水平显示菜单项

html - vmax 单元在 IE 中不工作

javascript - 在 javascript 和 CSS 中为禁用的输入文本框设置工具提示