.loading-button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 8px;
position: relative;
}
.loading-button:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
.loading-button .spinner {
position: absolute;
top: 50%;
left: 50%;
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s ease infinite;
transform: translate(-50%, -50%);
}
@keyframes spin {
to { transform: rotate(360deg); }
}
function startLoading(button) {
button.disabled = true;
button.querySelector('.button-text').style.display = 'none';
button.querySelector('.spinner').style.display = 'block';
// Simulate a delay for demo purposes
setTimeout(function() {
button.disabled = false;
button.querySelector('.button-text').style.display = 'block';
button.querySelector('.spinner').style.display = 'none';
alert('Operation completed');
}, 3000);
}