目前打印出来的日志显示在html是最下面显示的是最新的日志

目前打印出来的日志显示在html是最下面显示的是最新的日志,我需要最新日志显示在最上面,需要怎么修改,麻烦帮忙看看非常感谢


var showtime =function() {
    var date = new Date();
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
    var D = date.getDate() + ' ';
    var h = date.getHours() + ':';
    var m = date.getMinutes() + ':';
    var s = date.getSeconds();
    return Y+M+D+h+m+s;
}

function logs(){
    $("#log").html("");
    setInterval(function (){
        showtime();
    },1000);
    window.console = {
        log: function(str){
            var node = document.createElement("div");
            node.appendChild(document.createTextNode(showtime() +":"+str));
            document.getElementById("log").appendChild(node);
        }
    }
}

img

向前面追加内容。

log: function(str){
            var node = document.createElement("div");
            node.appendChild(document.createTextNode(showtime() +":"+str));
            $("#log").prepend(node);
 }
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632