Newbie: Dynamic back to top button

Newbie: Dynamic back to top button

Hi,

 I want to have back to button that appears itself when long text content (in a collapsible, accordion tab, page or others) is more than the viewport and then hide itself when content is scrolled to the top. Is there a way to do that?

 I tried the approach in this link: http://www.developerdrive.com/2013/07/using-jquery-to-add-a-dynamic-back-to-top-floating-button-with-smooth-scroll/ . It works fine with jQuery mobile + phonegap in iOS but in Android, once the "Back to Top" button appears, it does not hide.

Probably the scroll event of a page needs to be handled and not of the window? Any pointers welcome!

Thanks in advance and regards