This article shares the specific code of javascript to realize the 10-second countdown of payment for your reference. The specific content is as follows The effect diagram is as follows: This case is actually very simple. As long as you master the onclick function in the basics of js and the use of timers , you can quickly achieve such an effect. Let's take a look at how to do it~ First, you need two HTML files. Use HTML and CSS to write the initial page effects in the two files. I won’t go into details here. For details, see the following code Let's talk about the effects that js needs to produce: 1. Click on Pay in page 1 to jump to another file This is the effect we need to do So how do we jump between two pages? => Use The timing effect is very simple. Just use The code is as follows: Page 1: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> #btn{ display: block; margin:130px auto; width: 300px; height: 100px; font-size:30px; } </style> </head> <body> <button id="btn">Pay</button> <script> let btn = document.getElementById("btn"); btn.onclick=function(){ let con = window.confirm("Are you sure?"); if(con){ location.href='./payment.html'; } } </script> </body> </html> Page 2: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> #spa { font-size: 20px; color: red; } #total { width: 200px; height: 200px; background-color: rgba(169, 169, 169, 0.315); margin: 40px auto; border-radius: 20px; padding: 20px; position:flex; flex-direction: column; text-align: center; } #total h3 { padding-top: 20px; } #total button { margin-top: 30px } </style> </head> <body> <div id="total"> <h3>Congratulations, your payment was successful! </h3> <div> <span id="spa">10</span> <span>Automatically return to the home page after seconds</span> </div> <button id="btn">Return now</button> </div> <script> var spa = document.getElementById("spa"); let t = 10; setInterval(() => { t--; spa.innerText = t; if (t == 0) { location.href = "./pay 10 seconds.html"; } }, 400); var btn = document.getElementById("btn"); btn.onclick=function(){ location.href="./Pay 10 seconds.html" rel="external nofollow" } </script> </body> </html> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: IE8 Developer Tools Menu Explanation
>>: Zabbix combined with bat script to achieve multiple application status monitoring method
This article example shares the specific code of ...
1. Install JDK 1. Uninstall the old version or th...
1 Introduction PostgreSQL is a free software obje...
<br />In text design, we usually focus on th...
Preface Recently, during an interview, I was aske...
A joint index is also called a composite index. F...
1. Install MySQL (1) Unzip the downloaded MySQL c...
Use ktl tool to synchronize data from mysql to my...
The interviewer will sometimes ask you, tell me h...
cause I recently started to refactor the project,...
During normal project development, if the MySQL v...
This article will introduce how to query data in ...
1. Unzip the downloaded file as shown below . 2. ...
React is different from Vue. It implements route ...
The following analysis is about product design pr...