开发者

Convert this javascript function into jquery [closed]

开发者 https://www.devze.com 2023-02-17 17:47 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Could someone convert this plain javascript function to use jquery functions? Thanks!

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 Node开发者_如何学PythonList 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]); 
    }
};


This should do it:

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

Live demo: http://jsfiddle.net/simevidas/YxcYC/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号