jQuery 根本不起作用?

标签 jquery html css

<分区>


想改进这个问题吗? 通过 editing this post 添加细节并澄清问题.

关闭 8 年前

当我输入代码时,我用标题标记一个 div,然后放入 jQuery 代码,这样当我将鼠标悬停在它上面时它就会展开。但是,当我将它放入我的代码中时,它似乎不起作用?

我使用的代码在这里:

http://www.codecademy.com/courseBlaster14854_53a1c3f8631fe99231000802_deleted_53a1c3f8631fe99231000802_deleted/codebits/gioGOU/edit

最佳答案

看起来您没有链接到 jQuery 库。尝试将以下行之一添加到您的 <head> :

1.x

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

2.x

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

例如

<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="script.js"></script>
    <title> Risebush|home </title>
</head>

更新:

将您的 script.js 替换为:

$(document).ready(function () {
    $("#info").hover(function () {
        $(this).closest("#info").css("z-index", 1);

        $(this).animate({
            height: "400"
        }, "fast");

    }, function () {
        $(this).closest("#info").css("z-index", 0);
        $(this).animate({
            height: "250"
        }, "fast");
    });
});

关于jQuery 根本不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29551474/

上一篇:javascript - 如何使用 jQuery 在悬停时将 div 的图像源与另一个图像交换

下一篇:javascript - 使用带有 scrollTop 的原型(prototype)来激活 Class(js 类) 的实例(css 类)

相关文章:

javascript - 如何在执行悬停功能之前添加等待时间

javascript - 如果元素从一开始就不在页面中,则函数不会响应

html - 添加了多个空白链接的 CSS

javascript - devtools中的 "document count"指的是什么?

php - 多个交替行颜色

html - css中的移动菜单栏

html - 不可见滚动条改变了内容宽度

javascript - 按类别获取值

javascript - 渲染集合时避免使用多个 javascript_include_tag

jquery - 如何使用 JQuery 在 .each 循环中选择元素的子元素?