簡體   English   中英

我想讓一個鏈接在前 10 秒內不可點擊,然后讓它可點擊

[英]I want to make a link unclickable for the first 10 seconds and then make it clickable

在我的網站上,我想讓一個鏈接在頁面加載后的前 10 秒內無法點擊,然后讓它像普通鏈接一樣可以點擊。

我怎樣才能做到這一點?

  1. 創建 CSS class with.disabled 並將其添加到鏈接。
  2. 在 onload 事件中,使用 setTimeout 刪除 class “已禁用”並將時間設置為 10 秒。

 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" class="disabled">Google</a> </body> </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM