Scenario: The business needs to prompt a user notice page when clicking to shoot, and click next 5 seconds later. This is a JS timer function. This is done using jQuery
Effect:
html
<div style="text-align: center;" > <input type="button" value=" next "id="nextBtn" onclick=" btnFunction ()" disabled> <! </button id="nextBtn">Copy the code
css
# nextBtn {the font - size: 0.85 rem; color: white; background-color: orangered; Height: 2.125 rem; Width: 6.25 rem; Border - the radius: 0.9125 rem; border: none; }Copy the code
js
Var second = 5; Var time = setInterval (function () {if (second > 0) {$(" # nextBtn "). Val (" the next step (" + second + "s)"); second--; }else{$("#nextBtn").val(" next "); $("#nextBtn").removeAttr("disabled"); clearInterval(time); }}, 1000); Function btnfunction(){alert(" test click "); }Copy the code
If yes, the page will be automatically hidden after 5 seconds
// After 5 seconds, the window closes automatically! // window.setTimeout("window.close()",5000);Copy the code
Another page can be set
// window.open("1.html","_blank","top=0.left=0,width=300px,height=300px,toolbar=no");
Copy the code
Well, that’s it for this episode, and we’ll see you next time!