为什么我不能让这个非常简单的工具提示代码工作..?

时间:2014-03-02 21:42:14

标签: tooltip

是的......现在我带来了世界上最简单的剧本......虽然我无法让它发挥作用!

必须这个词,工具提示可以包含在.js文件中吗?它不存在于我的.js

我可以在脚本中包含更多.js文件,还是应该使用最新版本?

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("#outdoor img[title]").tooltip();
        });
</script>

<style type="text/css">

#tooltip
{
    display:none;
    font-size:12px;
    height:70px;
    width:160px;
    padding:20px;
    color:Gray;
}
#outdoor #nature
{

   margin-top:200px;

}

</style>
    <title></title>
</head>
<body>


<div id="tooltip"></div>

<div id="outdoor">
<img src="../img/forest.jpg" id="nature" alt="ghghg" title="I love the nature"/>
</div>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

您还没有在Javascript中编写tooltip()函数,这就是它无效的原因。

您需要在HTML文件中包含以下行:

<script type="text/javascript" src="http://jquery.bassistance.de/tooltip/jquery.tooltip.js"></script>
<link rel="stylesheet" href="http://jquery.bassistance.de/tooltip/jquery.tooltip.css" />