<span> Submit </span>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  height: 100vh;
  width: 100%;
  align-items: center;
  display: flex;
  justify-content: center;
  background-color: #161616;
}
.loading {
  border-radius: 50%;
  width: 24px;
  height: 24px;
  border: 0.25rem solid rgba(255, 255, 255, 0.2);
  border-top-color: rgb(255, 255, 255);
  animation: spin 1s infinite linear;
}
span {
  user-select:none;
  background-color: #ff5757;
  color: #000000;
  border: 2px solid;
  transition: 0.5s ease-in-out;
  width: 220px;
  font-size: 20px;
  height: 50px;
  cursor: pointer;
  position: relative;
  justify-content: center;
  align-items: center;
  display: flex;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
    var button = document.querySelector("span");
      button.addEventListener("click" ,()=>{
          button.innerHTML = `<div class="loading"></div>`
          setTimeout(() => {
              button.innerText = "Submited"
          }, 5000);
      })

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.