On my website I want to make a link unclickable for the first 10 seconds after the page loads and then make it clickable like a normal link after.
How can I achieve this?
CodePudding user response:
- Create CSS class with .disabled and add set it to link.
- In onl oad event, use setTimeout to remove the class "disabled" and set the time to 10sec.
window.onload = function (e) {
setTimeout(() => {
document.querySelector(".disabled").classList.remove("disabled");
}, 10000);
};
.disabled {
pointer-events: none;
}
<!DOCTYPE html>
<html>
<body>
<a href="https://google.com" >Google</a>
</body>
</html>