【问题标题】:functions does not run功能不运行
【发布时间】:2014-04-06 19:21:47
【问题描述】:

我想知道这段代码中我的问题是什么:

我希望我的 div 淡入

但我不知道为什么它没有像我想要的那样运行。我希望你能帮助我。

    <!DOCTYPE HTML>
    <html>
    <head>
    <title> my site </title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js">
    </script>
    <script type="text/javascript">
    $(document) .ready (function() {
      $("#frame").fadeIn(3000);
    });

    </script>
    <style type="text/css" media="all">
    * {margin:0 auto; padding:0;}
    body {background:#333;}
    #myframe {width:500px; height:300px; background:#006699;font:50px tahoma;
    text-align:center; color:#fff; line-height:100px;}
    </style>
    </head>
    <body>
      <div id="myframe">
         My site . 
    <br />
    THIS IS MY SITE.
      </div>
    </body>
    </html>

【问题讨论】:

  • but id don't know why it doesn't run as good as i want.你能量化一下如何你想要它吗?

标签: jquery document fadein


【解决方案1】:

CSS:

#myframe{
    ...
    display: none;
}

JS:

$(document) .ready (function() {
    $("#myframe").fadeIn(3000);
});

【讨论】:

    【解决方案2】:

    错字。

    $(document) .ready (function() {
       $("#myFrame").fadeIn(3000);
    });
    

    没有以frame 为 id 的元素。您只有 myFrame 作为 ID。所以上面应该可以工作。

    【讨论】:

      【解决方案3】:

      您声明了 myframe,但 javascript 是查找 id 框架

      <div id="frame">
      

      【讨论】:

        【解决方案4】:

        Jquery FadeIn 将仅显示您的 div,如果它已经 Given Display None

        http://api.jquery.com/fadein/ 获取完整文档。

        您必须更改您的代码。你有错误的 id frame 将其更改为 myframe

        $(document) .ready (function() {
              $("#myframe").fadeIn(3000);
            });
        

        并为#myframe{display:none;}添加样式

        Fiddle

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-04-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-12-05
          • 2021-06-26
          • 2023-03-25
          • 1970-01-01
          相关资源
          最近更新 更多