<tfoot id='RG0rD'></tfoot>

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

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

        <legend id='RG0rD'><style id='RG0rD'><dir id='RG0rD'><q id='RG0rD'></q></dir></style></legend>

        • <bdo id='RG0rD'></bdo><ul id='RG0rD'></ul>

      1. Jquery追加而不删除

        时间:2023-10-20

            <bdo id='NnEni'></bdo><ul id='NnEni'></ul>
              <tbody id='NnEni'></tbody>

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

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

                  <tfoot id='NnEni'></tfoot>
                • 本文介绍了Jquery追加而不删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我需要从特定类中获取内容并将其放入一个 div 中,我使用 append 来......我的问题是 append 删除了我附加的项目,我需要它留在那里,这是我的代码:

                  So I need to grab content from a specific class and put it in a div, which I use append for...my issue is that append removes the item I append, and I need it to stay there, Here is my code:

                  $(document).ready(function(){
                      var $content = $('#popupcontent');
                      var $window = $('#popupwindow');
                      $('.open').click(function(){
                          //alert('runnning');
                          var a = $(this).contents('span');
                          $content.append(a);
                          $window.fadeIn(300);
                      });
                      $('.close').click(function(){
                          //alert('running');
                              var a = $content.contents('span');
                          $window.fadeOut(300);
                          $('#popupcontent span').remove();
                      });
                  });
                  

                  那么如何在点击时从每个 .open span#popupcontents id 获取内容而不将其从 中删除.打开类?

                  So how can I get the content, when clicked, from each .open span to the #popupcontents id without removing it from the .open class?

                  向您展示我的意思:JSFIDDLE

                  注意:第二次单击链接时,它不会附加任何内容,因为该内容已从该类中删除,这不是我想要的

                  NOTE: the second time you click a link, it wont append any content because that content has been removed from that class, which is not what I want

                  注意 2:我不能简单地在 $('.close').click 函数中仅使用 append 而不是 remove,因为我无法检测到内容来自 .open 类的哪个实例.

                  NOTE2: I cannot simply just append instead of remove in the $('.close').click function because I cannot detect which instance of the .open class the content came from.

                  推荐答案

                  需要克隆元素并追加克隆:

                  You need to clone the element and append the clone:

                  $('.open').click(function(){
                      //alert('runnning');
                      var a = $(this).contents('span');
                      $content.append(a.clone());
                      $window.fadeIn(300);
                  });
                  

                  演示

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

                  上一篇:Jquery - 追加与追加 下一篇:将DIV堆叠在一起?

                  相关文章

                  <tfoot id='9m1Ms'></tfoot>
                      • <bdo id='9m1Ms'></bdo><ul id='9m1Ms'></ul>

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

                      <small id='9m1Ms'></small><noframes id='9m1Ms'>