Notification texts go here Contact Us Buy Now!
Posts

JavaScript Progressbar Loading

JavaScript Progressbar Loading
Chào mọi người.


Bài viết này mình sẽ hướng dẫn mọi người một thủ thuật về việc tạo một Processbar Loading sữ dụng Javascript

Thủ thuật này hoàn toàn đơn giản nhé mọi người.

Chúng ta bắt đầu.

Đầu tiên với thẻ HTML
<div id="myProgress">
  <div id="myBar"></div>
</div>

Tiếp theo đoạn mã CSS
#myProgress {
  width: 100%;
  background-color: grey;
}

#myBar {
  width: 1%;
  height: 30px;
  background-color: green;
}

Và cuối cùng là đoạn mã Javascript
var i = 0;
function move() {
  if (i == 0) {
    i = 1;
    var elem = document.getElementById("myBar");
    var width = 1;
    var id = setInterval(frame, 10);
    function frame() {
      if (width >= 100) {
        clearInterval(id);
        i = 0;
      } else {
        width++;
        elem.style.width = width + "%";
      }
    }
  }
}

Như vậy đã hoàn thành việc thủ thuật trên.

Chúc mọi người thành công.

Demo tại đây.

About the Author

Chia sẽ kiến thức và tư duy sáng tạo của bản thân mỗi ngày
hung.pro.vn
theme.pro.vn
ihung.name.vn

2 comments

  1. chất lượng
  2. chất lượng đó a
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.
NextGen Digital Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...