Sort DOM elements to order array with jQuery

后端 未结 3 1084
轮回少年
轮回少年 2020-12-18 12:02

A moment ago I asked this question: javascript sort array to align with order array based on what turned out to be a false premise. (I\'ve been up for too long, give me a br

3条回答
  •  孤城傲影
    2020-12-18 12:46

    Try this.

    Detaching the elements from the DOM tree may speed up the process.

    $modules.detach();
    
    var len = order.length,
        temp = [];
    
    for( var i = 0; i < len; i++ ) {
      temp.push( $modules[ order[i] ] );
    }
    
    $("#moduleWrap").append( temp );
    

    Fiddle here http://jsfiddle.net/rEFu3/ ​

提交回复
热议问题