console
const count = document.querySelector(".count");
const add = document.querySelector('.add');
const dec = document.querySelector('.dec');
var num = 0;
count.innerHTML = `${num}`;
add.addEventListener("click",function(){
count.innerHTML = ``;
num+=1;
count.innerHTML = `${num}`;
});
dec.addEventListener("click",function(){
count.innerHTML = ``;
num-=1;
count.innerHTML = `${num}`;
});
<div class="content">
<h1 class="count"></h1>
<div class="event">
<button class="add">加一</button>
<button class="dec">减一</button>
</div>
</div>
.content{
width: 100%;
height: 500px;
margin-top: 100px;
}
.count{
width: 100%;
text-align: center;
color: #93efed;
}
.event{
display: flex;
justify-content: center;
}
button{
width: 75px;
height: 50px;
font-size: 25px;
color: #44aec2;
outline: none;
border-radius: 20px;
background: #362999;
}
button:hover{
cursor: pointer;
}