+ 5

Why onscroll doesn't works on child element?[ SOLVED]

https://code.sololearn.com/W5nF88ugzZFQ/?ref=app

20th Jul 2020, 3:35 PM
Abhay
Abhay - avatar
4 Réponses
+ 4
Because your #child doesn't have a content exceeding its border and an overflow property like your #parent has Try adding a second inner child with height 600px and an overflow-y on #child.
20th Jul 2020, 3:40 PM
Gordon
Gordon - avatar
+ 2
If you want to shortcut getElementById by treating the id as window property, you need to avoid name collision with already existing window properties. Try renaming to parent1 and you can shortcut.
20th Jul 2020, 4:17 PM
Gordon
Gordon - avatar
+ 1
Gordon ty I thought onscroll works on elements that is scrollable ,so i attached it on the child element ,i tried it with parent but it didn't work before because I was trying to attach the onscroll on global id (parent ) instead of selecting it first ,
20th Jul 2020, 3:58 PM
Abhay
Abhay - avatar
0
Gordon thks again
20th Jul 2020, 5:41 PM
Abhay
Abhay - avatar