簡單的進度條兒

今晚學了ajax
將請求發送到服務器

var xmlhttp = XMLHttpRequest;
xmlhttp.open("GET/POST","URL",true/false是否異步);
xmlhttp,send(string);僅用於post

學到了一個簡單的進度條

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
<style>
    #progress{
        width:200px;
        height:30px;
        border: solid black 1px;
    }
    .percent{
        width: 0px;
        height: 30px;
        background-color: blue;
    }
</style>
</head>
<body>
<div id="progress">
    <div class="percent"></div>
</div>
<script type="text/javascript">
    var xhr = new XMLHttpRequest();
    xhr.open("GET","./2.html",true); //get需要url
    xhr.send();
    xhr.onprogress = function (e) {
            let per = document.getElementsByClassName('percent')[0];
            per.style.width = e.loaded / e.total *200 +"px";
            console.log(e.loaded / e.total);
        }
</script>
</body>
</html>

爲什麼沒有for循環他也能一個一個蹦出來,明天腦殼清醒了再想想
//繼清醒之後,他之前有一個
再來一些菜鳥的學習筆記:
var a = {}; 聲明一個對象 傻子!
-webkit-overflow-scrolling:touch 屬性控制元素在移動設備上是否使用滾動回彈效果.touch: 使用具有回彈效果的滾動, 當手指從觸摸屏上移開,內容會繼續保持一段時間的滾動效果。繼續滾動的速度和持續的時間和滾動手勢的強烈程度成正比。同時也會創建一個新的堆棧上下文。auto: 使用普通滾動, 當手指從觸摸屏上移開,滾動會立即停止。ios

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章