Javascript 我需要使一个事件发生在我的网站上,如果一个按钮已点击x次
我想在我的网站上创建一个不可见的部分,在Button被点击x次后将其扩展。我想我已经满足了你的要求 工作演示: HTML: JS:Javascript 我需要使一个事件发生在我的网站上,如果一个按钮已点击x次,javascript,html,jquery,css,Javascript,Html,Jquery,Css,我想在我的网站上创建一个不可见的部分,在Button被点击x次后将其扩展。我想我已经满足了你的要求 工作演示: HTML: JS: <div id='hidden-div'> Hello </div> <span id='show-count'>0</span> <button onClick=(toggleDiv())> Click me </button> #hidden-div{ border:
<div id='hidden-div'>
Hello
</div>
<span id='show-count'>0</span>
<button onClick=(toggleDiv())>
Click me
</button>
#hidden-div{
border:1px solid black;
position:absolute;
top:0;
left:0;
width:0;
height:200px;
}
.show-div{
animation: 2s showDiv forwards;
}
@keyframes showDiv {
from{width:0;}
to{width:400px;}
}
let count = 0;
let showOn = 10;
toggleDiv = () => {
if(count < showOn -1 ){
count++
document.getElementById("show-count").innerHTML = count;
document.getElementById('hidden-div').classList.remove("show-div")
return
}
document.getElementById('hidden-div').classList.add("show-div")
count = 0;
}