jquery - Find offset relative to parent scrolling div instead of window -



jquery - Find offset relative to parent scrolling div instead of window -

i have scrolling element within window.

say partition having class "currentcontainer" overflow auto , partition contains huge amount of text big plenty scrolling.

now have calculations based on how much "currentcontainer" has scrolled downwards + offset of specific element parent scrolling div (that "currentcoantainer").

but while calculating offset offset of inner kid element regard window not "currentcontainer".

js fiddle

@shikkediel tried using position().top instead of offset().top is giving same result. have @ :

js fiddle 2

please not suggest using :

$("<reference of scrolling element").scrolltop() + $("<reference of kid element offset want calculate>").offset().top

because going complicate actual calculations beyond this.

reason why not want utilize above mentioned approach trying modify existing code messy working regard window have update starts working relative parent scrolling div.

i tried using above mentioned approach opened box of crabs me. because functions much tightly coupled. think if can simple , straight solution i.e. replacing .offset().top else.

i tried debugging code , still no luck have added actual code @ http://jsfiddle.net/arpitajain/kwkm7com/

p.s. actual code not finish think rest of code not needed error.

you subtract offset of parent element offset of kid element. complicate other things need well?

$(".getoffset").offset().top - $(".getoffset").offsetparent().offset().top

http://jsfiddle.net/kmlr07oh/2/

jquery css scroll overflow scrolltop

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -