Href button | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Href button

href=#top in my switch doesnt work How do i make an element take me to the top of the page when i click it https://code.sololearn.com/WgQC6iYwntCo/?ref=app (switch at bottom)

13th Jan 2019, 10:32 AM
∞ Infinítє Сσdєr ∞
∞ Infinítє Сσdєr ∞ - avatar
2 Answers
+ 3
You have given the address as #top but there is no element with the id top. Create that in the top of the body. But the formal way of getting top is using js. Use document.scrollTop = 0 to go to top
13th Jan 2019, 10:43 AM
Seniru
Seniru - avatar
0
ohh thanks
13th Jan 2019, 10:44 AM
∞ Infinítє Сσdєr ∞
∞ Infinítє Сσdєr ∞ - avatar