<tfoot id='njv8V'></tfoot>

    <i id='njv8V'><tr id='njv8V'><dt id='njv8V'><q id='njv8V'><span id='njv8V'><b id='njv8V'><form id='njv8V'><ins id='njv8V'></ins><ul id='njv8V'></ul><sub id='njv8V'></sub></form><legend id='njv8V'></legend><bdo id='njv8V'><pre id='njv8V'><center id='njv8V'></center></pre></bdo></b><th id='njv8V'></th></span></q></dt></tr></i><div id='njv8V'><tfoot id='njv8V'></tfoot><dl id='njv8V'><fieldset id='njv8V'></fieldset></dl></div>
  1. <legend id='njv8V'><style id='njv8V'><dir id='njv8V'><q id='njv8V'></q></dir></style></legend>

    <small id='njv8V'></small><noframes id='njv8V'>

        <bdo id='njv8V'></bdo><ul id='njv8V'></ul>
    1. Jquery - 追加与追加

      时间:2023-10-20
          <tbody id='9yYiH'></tbody>

        • <small id='9yYiH'></small><noframes id='9yYiH'>

          <i id='9yYiH'><tr id='9yYiH'><dt id='9yYiH'><q id='9yYiH'><span id='9yYiH'><b id='9yYiH'><form id='9yYiH'><ins id='9yYiH'></ins><ul id='9yYiH'></ul><sub id='9yYiH'></sub></form><legend id='9yYiH'></legend><bdo id='9yYiH'><pre id='9yYiH'><center id='9yYiH'></center></pre></bdo></b><th id='9yYiH'></th></span></q></dt></tr></i><div id='9yYiH'><tfoot id='9yYiH'></tfoot><dl id='9yYiH'><fieldset id='9yYiH'></fieldset></dl></div>

              <bdo id='9yYiH'></bdo><ul id='9yYiH'></ul>
                <tfoot id='9yYiH'></tfoot>

              1. <legend id='9yYiH'><style id='9yYiH'><dir id='9yYiH'><q id='9yYiH'></q></dir></style></legend>
              2. 本文介绍了Jquery - 追加与追加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                谁能解释一下为什么常规的 Append into a loop 比 AppendTo 效果更好?

                Can somebody explain me why regular Append into a loop works better than AppendTo?

                //Using Regular Append
                var ul = $("<ul></ul>");
                $("#myDiv").empty().append(ul)
                
                $.each(movies, function (count, item) {
                    var id = 'li_' + count;
                    ul.append('<li id=' + id + '>' + item + '</li>');
                
                    $('#' + id).click(function () { });
                });
                
                //Using AppendTo
                var div = $("#myDiv").empty(),
                    ul = $("<ul></ul>").appendTo(div);
                
                $.each(movies, function (count, item) {
                    $('<li>' + item + '</li>').click(function () { }).appendTo(ul);
                });
                

                结果http://jsperf.com/sdp-jquery-append/3

                推荐答案

                append(content) 将内容追加到每个匹配元素的内部.

                append(content) appends content to the inside of every matched element.

                appendTo(selector) 将所有匹配的元素附加到另一组指定的元素.

                appendTo(selector) appends all of the matched elements to another specified set of elements.

                这篇关于Jquery - 追加与追加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在javascript中的ul中附加一个数组? 下一篇:Jquery追加而不删除

                相关文章

                <i id='ujjSp'><tr id='ujjSp'><dt id='ujjSp'><q id='ujjSp'><span id='ujjSp'><b id='ujjSp'><form id='ujjSp'><ins id='ujjSp'></ins><ul id='ujjSp'></ul><sub id='ujjSp'></sub></form><legend id='ujjSp'></legend><bdo id='ujjSp'><pre id='ujjSp'><center id='ujjSp'></center></pre></bdo></b><th id='ujjSp'></th></span></q></dt></tr></i><div id='ujjSp'><tfoot id='ujjSp'></tfoot><dl id='ujjSp'><fieldset id='ujjSp'></fieldset></dl></div>

                <small id='ujjSp'></small><noframes id='ujjSp'>

              3. <legend id='ujjSp'><style id='ujjSp'><dir id='ujjSp'><q id='ujjSp'></q></dir></style></legend>
                  <bdo id='ujjSp'></bdo><ul id='ujjSp'></ul>

                    <tfoot id='ujjSp'></tfoot>