Skip to content
Advertisement

jQuery get the children distance from parent div

I have this HTML:

JavaScript
JavaScript

Based on this class sh-sidebar-content I need to get the distance of each li element.

I can get the height of sh-sidebar-content class using

JavaScript

It shows me the height value based on the window height. For eg: 735.

So, Now, I need to get the distance from this value of the li element.

Advertisement

Answer

You can use position for this. Get the base point (div) position, then get each li‘s position, then subtract.

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