gpt4 book ai didi

javascript - 将此 javascript 函数转换为 jquery

转载 作者:行者123 更新时间:2023-11-28 21:24:48 25 4
gpt4 key购买 nike

有人可以将这个普通的 javascript 函数转换为使用 jquery 函数吗?谢谢!

move_object = function (from, to) {
var i, // local variable
childnodes_length; // number of child nodes
// test if "from" cell is equal to "to" cell then do nothing
if (from === to) {
return;
}
// define childnodes length before loop (not
// in loop because NodeList objects in the DOM are live)
childnodes_length = from.childNodes.length;
// loop through all child nodes
for (i = 0; i < childnodes_length; i++) {
// '0', not 'i' because NodeList objects in the DOM are live
to.appendChild(from.childNodes[0]);
}
};

最佳答案

这应该可以做到:

$(from).contents().appendTo(to);

现场演示: http://jsfiddle.net/simevidas/YxcYC/

关于javascript - 将此 javascript 函数转换为 jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5344405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com