Javascript 将一个元素从div移动到另一个-不工作

Javascript 将一个元素从div移动到另一个-不工作,javascript,jquery,html,move,Javascript,Jquery,Html,Move,我正在尝试将Grid3移动到Grid2——我正在使用这段代码,但它不起作用,我做错了什么 另外,是否可以将Grid3中的Div的一半移动到Grid1,另一半移动到Grid2 JS $("#grid3").appendTo("#grid2"); HTML <div class="wrapperA1"> <div class="content"> <div id="home-sectionD"&g

我正在尝试将Grid3移动到Grid2——我正在使用这段代码,但它不起作用,我做错了什么

另外,是否可以将Grid3中的Div的一半移动到Grid1,另一半移动到Grid2

JS

$("#grid3").appendTo("#grid2");
HTML

        <div class="wrapperA1">
            <div class="content">
                <div id="home-sectionD">
                    <div id="grid1"><!--Gird 1-->   

                        <article class="testimonial">
                        <img alt="Neal Kilburne​​" src="assets/images/neal kilburne​​.jpg"/>
                            <div>
                                <h3>Neal Kilburne​​</h3>
                                <p>CEO, iTEQ Global www.iteqglobal.com</p>
                                    <br>
                                <p>“Loai is a great asset to our company and provides us with great and quick responses,Such a talented designer which we have the honour of working with.” 2011 - 2012</p>
                            </div>  
                        </article>

                        <article class="testimonial">
                            <div>
                                <h3>Amanda Chui​</h3>
                                <p>Owner of www.beautyroom.ca</p>
                                    <br>
                                <p>Just what my website needed! When I had finished my website, I felt that it was missing something,so I enlisted in the help of Loai. He did a great job of giving my website the professional and polished look it needed without having me wait for days on end. Thanks, Loai!” June 23, 2012</p>
                            </div>
                        </article>

                    </div><div id="grid2"><!--Gird 2-->     

                        <article class="testimonial">
                            <img alt="Geeta Martinez" src="assets/images/geeta martinez.jpg"/>
                            <div>
                                <h3>Geeta Martinez</h3>
                                <p>Lawyer &amp; Business Consultant</p>
                                    <br>
                                <p>"Leo did a great job! He designed and put together several websites for me in less than a week. He was incredibly patient and flexible throughout the whole process, and took a lot of the stress out of the whole situation for me. He is a really nice guy to work with - I really appreciated his approach! I would definitely recommend working with him". July 14, 2013</p>
                            </div>  
                        </article>

                        <article class="testimonial">
                            <div>
                                <h3>Richard Jackson</h3>
                                <p><em>Photographer www.rjpstudios.co.uk​</em></p>
                                    <br>
                                <p>“Loai designed my website last year on wix though I could have done it myself loai added a proffesional touch to the design which is so important in creating the best first impeson.” 2013</p>
                            </div>
                        </article>  

                    </div><div id="grid3"><!--Gird 3-->         

                        <article class="testimonial">
                            <img alt="Glen Eric Huysamer" src="assets/images/glen eric huysamer.jpg"/>
                            <div>
                                <h3>Glen Eric Huysamer​</h3>
                                <p>Specialist Service Provider.</p>
                                    <br>
                                <p>“I would like to take this opportunity to warn people who might consider using Loai Design Studio. You will have to buckle up and strap yourself in as this young designer and associates take you through the process of creating your design needs. I was pleasantly surprised from start to finish, and can say that even though Loai took control of the creative process the end result felt like it was mine. You can not go wrong with this young lad, go ahead surprise yourself”. December 30, 2011</p>
                            </div>
                        </article>

                        <article class="testimonial">
                            <div>
                                <h3>Ciprian Filip​</h3>
                                <p>Founder of Pontomat.ro​</p>
                                    <br>
                                <p>“Worked with Loai on designing exposure of our social media presence on Facebook for our E-commerce initiative. He is very passionate and expert in his field of work, coming with breakthrough innovations in real time. He is able to manage an end to end social media exposure with accent on clarity, effectiveness and innovation. His working capabilities are awesome and I am sure that he will make good contribution to any project he works on.”  August 4, 2011</p>
                            </div>
                        </article>

                    </div>                      
                </div>
            </div>
        </div>

尼尔·基尔伯恩​​
iTEQ Global首席执行官www.iteqglobal.com


“Loai对我们公司来说是一笔巨大的资产,为我们提供了巨大而快速的响应,我们有幸与这样一位才华横溢的设计师共事。”2011-2012年

阿曼达·崔​ www.beutyroom.ca的所有者


正是我的网站所需要的!当我完成我的网站时,我觉得它遗漏了什么,所以我加入了Loai的帮助。他为我的网站提供了它所需要的专业和精致的外观,而不是让我连续几天等待,这一点做得很好。谢谢,洛艾!”2012年6月23日

吉塔·马丁内斯 律师及;商务顾问


“利奥做得很好!他在不到一周的时间里为我设计并建立了几个网站。在整个过程中,他表现出了难以置信的耐心和灵活性,为我从整个情况中消除了很多压力。他是一个很好的合作伙伴——我真的很欣赏他的方法!我绝对推荐与他合作。”2013年7月14日

理查德·杰克逊 摄影师www.rjpstudios.co.uk​


“Loai去年在wix上设计了我的网站,虽然我自己也可以做到。Loai在设计中加入了专业元素,这对于创造最佳first Imperson非常重要。”2013年

格伦·埃里克·休萨默​ 专业服务提供商


“我想借此机会提醒那些可能考虑使用LoAI设计工作室的人。你将不得不扣上腰带,让这个年轻的设计师和同事带你进入创造你的设计需求的过程中。我从开始到结束都感到惊喜,即使洛伊控制了我的设计。e创意过程最终的结果就像是我的。你不能对这个年轻人出错,去吧,给自己一个惊喜。”2011年12月30日

西普里安菲利普​ Pontomat.ro的创始人​


“与Loai合作,为我们的电子商务计划在Facebook上设计社交媒体曝光。他对自己的工作领域非常热情和专业,实时实现突破性创新。他能够管理端到端社交媒体曝光,强调清晰性、有效性和创新。他的工作能力Lites非常棒,我相信他会为他所从事的任何项目做出贡献。”2011年8月4日


似乎对我有用()

在浏览器实际处理所有html之前,您调用append可能太早。请尝试将append函数包装到函数中

$(document).ready(function () {
    $("#grid3").appendTo("#grid2");
});
移动确实有效(如果您在加载文档后运行代码,例如在
$(document).ready()
事件中)。检查开发人员控制台中的元素(如果您使用的是Chrome),查看
#grid3
是否实际位于
#grid2
中,如是

<div id="grid2">...
    <article...>
    <article...>
    <div id="grid3">...
</div>
。。。
...

如果要将
grid3
的内容移动到
grid2
中,则必须使用
$(“#grid3”)。查找('article')。附录(“#grid2”)
这将从
grid3
中删除文章并将其插入
grid2
。移动部分可以通过分离
文章
并将一个插入
grid1
和另一个插入
grid2

来完成。您从哪里调用jQuery代码?在HTML之前?它是否包装在
$(函数(){…})
?它是在某种事件上吗?这里没有足够的信息来提供答案。追加是由事件触发的吗?你确定事件被正确触发了吗?修复了这个问题,抱歉信息太多,我正在尝试使它在屏幕大小低于770px时追加它…我正在使用以下代码,但它不是工作正常!
$(文档)。加载($(窗口)。绑定(“resize”,listenWidth));函数listenWidth(){if($(窗口)。w