我需要禁用指针(光标),然后在设置的时间后启用它

时间:2019-04-25 19:08:16

标签: javascript

我想在6秒钟内禁用鼠标光标(因此所有元素均不可单击),然后再次启用它。

1 个答案:

答案 0 :(得分:-3)

您可以将不可见的<div>放在前面(具有完整的窗口大小)

function test() {
  console.log('button clicked')
}

function dis() {
  curtine.classList.toggle('show')
  setTimeout(x=>curtine.classList.toggle('show'),6000);
}
#curtine { 
  top:0;
  left:0;
  position: fixed; 
  background: rgba(0,0,0,0.15); /* change 15 to 0*/
  width: 100vw; 
  height: 100vh;
  display: none;
}

#curtine.show { display: block; cursor: none }
<button onclick="test()">Some button</button>

<button onclick="dis()">disable cursor</button>

<div id=curtine></div>