Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用 ember.js 移动一个元素。最佳做法是什么?
“移动”并不意味着我在坐标 XY 上移动元素。这意味着我更改了要移动的元素的父元素。另外,我想为元素移动添加css3动画。
我想做如下。
前
<div id="foo"> <div id="moved"></div> </div> <div id="bar"></div> </div>
后
<div id="foo"> </div> <div id="bar"> <div id="moved"></div> </div>
除了动画之外,整个方法也可能是错误的,如果你的代码真的像那样简单,你可以使用 jQuery 安全地将元素从它的旧位置分离并将其附加到它的目标元素。如果您使用 Chrome 开发人员工具并执行检查元素,并看到与 ember 相关的标记,而您不知道它在移动元素的源和目标之间做了什么,那么使用 jQuery 可能会搞砸一些事情。
var d = $("#moved").detach(); d.appendTo("#bar");
要不就
$("#moved").appendTo("#bar");