When getting element by class name, don't forget the return value is an array; Hence this code:
document.getElementByClassName("dropdown-menu").scrollTop = 0
Would not work. Use code below instead.
document.getElementByClassName("dropdown-menu")[0].scrollTop = 0
I figured other people might encounter a similar problem as I did; so this should do the trick.