【问题标题】:jQuery Animation HelpjQuery 动画帮助
【发布时间】:2010-10-07 21:02:56
【问题描述】:

我从查询中返回了动态数量的 div,所有这些都使用类#li。我希望它们都平滑地淡入而不是仅仅出现。到目前为止,我正在使用此代码:

function loadTables() {
                $.get("display.php", { server: Server, username: Username, password: Password, database: Database, content: "tables" },
                    function(data){
                        html = ''
                        $(data).find("table").each(function() {
                            html = html + "<div id='li'>" + $(this).text() + "</div>";
                            });
                        $('#content').html(html);
                        $('#li').hide();
                        $('#li').fadeIn('slow');
                    }
                );
            }

但问题是,动画只适用于第一个 div。它的动画效果很好。但所有其余的只是出现。 jQuery.com 上的文档说它对所有匹配的元素都这样做,但是,它似乎没有这样做。我该如何解决这个问题?

【问题讨论】:

    标签: jquery animation


    【解决方案1】:

    XML/HTML 中的 ID 是唯一的。您应该将 id 更改为 class,然后调用 $(".li") 来代替 $("#li")。 jQuery 很可能在第一次出现时停止,因为这是标准的。

    【讨论】:

      【解决方案2】:

      您不能为多个元素使用相同的 id。
      尝试将 id 替换为 class。

      【讨论】:

        猜你喜欢
        • 2011-03-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-20
        • 2011-01-27
        • 1970-01-01
        相关资源
        最近更新 更多