Skip to content
Advertisement

Hide element if scrolled to maximum of container

I worked with this code:

JavaScript
JavaScript
JavaScript

If you scroll horizontally to the end of the #text element, the gradient on the right side should be hidden. If you scroll to the left side again, the gradient should be shown again.

Has anyone an idea how to program that?

Advertisement

Answer

You need to subtract the offsetWidth from the scrollWidth:

JavaScript

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement