javascript – 在HTML页面上包含JS文件的问题

我正在尝试使用工具提示jQuery插件.这就是我所拥有的< head> of index.html:

<head>
    <title>Index</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="js/simpletip-1.3.1.min.js" type="text/javascript"></script>
    <script src="js/homepage.js" type="text/javascript"></script>
</head>

这是在js / homepage.js:

$(document).ready(function() {
    // meaningless functions

    $('.supported_hosts').simpletip({
        fixed: true,
        position: 'right',
        content: 'test content.'
    });
});

但由于某种原因,工具提示没有显示.但它确实显示我是否在索引页面上包含工具提示功能.有没有办法让这个工作没有索引页面上的工具提示功能,但在外部文件?谢谢.

解决方法:

我从来没有使用过最简单的插件,但我复制并粘贴了你的标题和你的js代码,一切似乎都运行得很好.

我链接到最新版本的jquery并下载了simpletip.js的新副本,并在第一次尝试时使用.

唯一的区别是/可能:
  – 我不知道你在html中调用’supported_hosts’类的代码是什么样的.
  – simpletip.js文件的名称我没有在下载时更改它,所以我会检查你的文件名和相对位置.

对不起,没有更多的东西,但你有什么为我工作,这里是我用的全部代码,这可以帮助你:

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <title>Index</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="jquery.simpletip-1.3.1.min.js" type="text/javascript"></script>
    <script src="homepage.js" type="text/javascript"></script>
</head>

<body>
     <span class="supported_hosts">Tool Tips here</span>
</body>
</html>

你给的Javascript:

$(document).ready(function() {
    // meaningless functions

    $('.supported_hosts').simpletip({
        fixed: true,
        position: 'right',
        content: 'test content.'
    });
});

我在这里下载了simpletip.js:
http://code.google.com/p/jquery-simpletip/downloads/detail?name=jquery.simpletip-1.3.1.min.js&can=2&q=

我只想仔细检查你的相对路径和类命名.你的代码看起来不错.

上一篇:javascript – 用于nvd3散点图的自定义x轴工具提示


下一篇:mysql 架构 ~ 异地多活