jQuery slideDown 脚本在简单的代码示例中不起作用

jQuery slideDown script not working in simple code example

本文关键字:不起作用 代码 slideDown 脚本 简单 jQuery      更新时间:2023-09-26
<!DOCTYPE html>
<html>
    <head>
        <title>
        </title>
        <style>
        </style>
        <script type="text/javascript">
            $(document).ready(function {
          $('img').slideDown('slow');
      });
        </script>
    </head>
    <body>
        <img src="images'sjmak-music-logo.jpeg"/>
    </body>
</html>

上面的简单代码示例不起作用;我试图简单地使图像从屏幕顶部向下滑动,但它保持静态。 我还尝试在图像上使用"display: none",但图像保持隐藏状态,而不是从顶部向下滑动。

你需要包含jQuery库文件才能使用jQuery方法。

在下面的示例中,添加了 jquery cdn 版本。同样要向下滑动图像,它必须首先被隐藏

<!DOCTYPE html>
<html>
    <head>
        <title>
        </title>
        <style>
        </style>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
          $('img').slideDown('slow');
      });
        </script>
    </head>
    <body>
        <img src="images'sjmak-music-logo.jpeg" style="display: none"/>
    </body>
</html>

演示:小提琴