<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> <style> p { font-size: 400px; } </style> </head> <body> <p>?</p> <a href="javascript:void(0)">点击</a> </body> </html>
The above code will return to the top of the page after clicking.
Solution to the problem:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> <style> p { font-size: 400px; } </style> </head> <body> <p>?</p> <a href="javascript:void(0)">点击</a> </body> </html>
Okay, the problem is solved\(^o^)/~
If you want to add a click event to the a tag, you can write like this
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> <style> p { font-size: 400px; } </style> </head> <body> <p>?</p> <a href="javascript:void(0)" onclick="aClick()">点击</a> </body> <script> function aClick() { alert("晨落梦公子"); } </script> </html>
The above is the problem that the editor introduces to you on how to click the a tag to return to the top of the page in JS. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. of. I would also like to thank you all for your support of the PHP Chinese website!
For more related articles on how to implement clicking the a tag to return to the top of the page in JS, please pay attention to the PHP Chinese website!