jquery 計數器
by j91157j91157
HTML
<div id="RR">
<button id="myB"> 按我! </button>
<br> <p id='FF'></p>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
CSS
#RR {
background-color: lightblue;
width: 50vw;
height: 50vw;
text-align: center;
}
#myB {
position: absolute;
text-align: center;
top: 25vw;
width: 15vw;
}
#FF {
position: absolute;
top: 10vw;
width: 25vw;
font-family: fantasy;
font-size: 10vw
}
JavaScript
$("#myB").click(
function() {
count = 0
//console.log (count);
setTimeout(gg, 1000);
}
)
function gg(){
count++;
$("#FF").text (count);
setTimeout(gg, 1000);
}