+ 2

Scroll

I have written a code. I want my div element to scroll 10 px vertically each time when i click the move button but it's happening only once. https://code.sololearn.com/WCo41HD6s85Z/?ref=app

12th Sep 2020, 8:48 PM
Adnan Ur Rehman
Adnan Ur Rehman - avatar
3 Réponses
+ 1
Try this if works document.getElementById("dn").scrollTop += "10"; also add some content to it to see effect better way
13th Sep 2020, 12:41 AM
Divya Mohan
Divya Mohan - avatar
+ 3
Also don't forget to change the quotation marks between 10 in line 12. Or else each time you press it it would add two strings like "10" + "10" = "1010"
13th Sep 2020, 2:34 AM
Steve Sajeev
Steve Sajeev - avatar
0
Thanks its working now
13th Sep 2020, 11:27 AM
Adnan Ur Rehman
Adnan Ur Rehman - avatar