<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>JavaScript</title>
  <style>
    #container {
      width: 500px;
      height: 40px;
      padding: 10px;
      border: 1px solid #999999;
    }
    #progressbar {
      width: 0px;
      height: 40px;
      background-color: #000099;
    }
  </style>
  <script>
    function initiate() {
      const container = document.getElementById("container");
      container.addEventListener("mousemove", movebar);
      const bar = document.getElementById("progressbar");
      bar.style.pointerEvents = "none";
    }
    function movebar(event) {
      let widthbar = event.offsetX - 10;
      if (widthbar < 0) {
        widthbar = 0;
      } else if (widthbar > 500) {
        widthbar = 500;
      }
      const bar = document.getElementById("progressbar");
      bar.style.width = widthbar + "px";
    }
    window.addEventListener("DOMContentLoaded", initiate);
  </script>
</head>
<body>
  <section>
    <h1>Level</h1>
    <div id="container">
      <div id="progressbar"></div>
    </div>
  </section>
</body>
</html>