【问题标题】:jQuery FadeIn() and etc are not working , browser considers that they are not function at alljQuery FadeIn() 等不起作用,浏览器认为它们根本不起作用
【发布时间】:2019-01-05 20:47:23
【问题描述】:

在这段代码中,我要淡入元素

$("button").on("click", function () {
    $('div').fadeIn("2000", function () {
    })
})

在 Google Chrome 开发者部分它告诉我 fadeIn() 不是一个函数!

怎么了?我能做些什么?任何帮助表示赞赏

【问题讨论】:

标签: javascript jquery css jquery-ui


【解决方案1】:

首先,您需要将 Jquery 库添加到您的 javascript 代码之前的正文末尾。

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

然后你可以使用fadeIn函数。此外,您应该以正确的方式使用 jquery 选择器。希望此示例对您有所帮助。

    $( "#clickme" ).click(function() {
        $( "#ContentDIV" ).fadeIn( "slow", function() {
            // Animation complete
        });
    });
.test {
            background-color: grey;
            padding: 20px;
            display: none;
        }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="clickme">Click Me</button>
 
<div id="ContentDIV" class="test">
    This is a test DIV
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-31
    • 1970-01-01
    • 2015-07-27
    • 2011-02-13
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多