Discuss / JavaScript / 作业

作业

Topic source
    var test_list =document.getElementById("test-list");
    print(Array.isArray(test_list.children))
    var sorted_children =[]
    for ( x of test_list.children){
    sorted_children.push(x)
    }
    sorted_children.sort(function (x,y) {
    return x.innerText >y.innerText ;
    })
    for ( x of sorted_children){
    test_list.appendChild(x)
    }

  • 1

Reply