Home  >  Article  >  Web Front-end  >  How to implement the problem of clicking the a tag to return to the top of the page in JS

How to implement the problem of clicking the a tag to return to the top of the page in JS

高洛峰
高洛峰Original
2017-01-21 10:06:181686browse

<!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:

76c82f278ac045591c9159d381de2c57
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
 a80eb7cbb6fff8b0ff70bae37074b813
 b2386ffb911b14667cb8f0f91ea547a7Title6e916e0f7d1e588d4f442bf645aedb2f
 c9ccee2e6ea535a969eb3f532ad9fe89
  p {
   font-size: 400px;
  }
 531ac245ce3e4fe3d50054a55f265927
9c3bca370b5104690d9ef395f2c5f8d1
6c04bd5ca3fcae76e30b72ad730ca86d
e388a4556c0f65e1904146cc1a846bee?94b3e26ee717c64999d7867364b1b4a3
28005f15af468ab3f7bae64fb648e307点击5db79b134e9f6b82c0b36e0489ee08ed
36cc49f0c466276486e50c850b7e4956
73a6ac4ed44ffec12cee46588e518a5e

Okay, the problem is solved\(^o^)/~

If you want to add a click event to the a tag, you can write like this

76c82f278ac045591c9159d381de2c57
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
 a80eb7cbb6fff8b0ff70bae37074b813
 b2386ffb911b14667cb8f0f91ea547a7Title6e916e0f7d1e588d4f442bf645aedb2f
 c9ccee2e6ea535a969eb3f532ad9fe89
  p {
   font-size: 400px;
  }
 531ac245ce3e4fe3d50054a55f265927
9c3bca370b5104690d9ef395f2c5f8d1
6c04bd5ca3fcae76e30b72ad730ca86d
e388a4556c0f65e1904146cc1a846bee?94b3e26ee717c64999d7867364b1b4a3
8684ef87c7ae5da5b0dc8f2aac4e658f点击5db79b134e9f6b82c0b36e0489ee08ed
36cc49f0c466276486e50c850b7e4956
3f1c4e4b6b16bbbd69b2ee476dc4f83a
 function aClick() {
  alert("晨落梦公子");
 }
2cacc6d41bbb37262a98f745aa00fbf0
73a6ac4ed44ffec12cee46588e518a5e

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn