javascript - Keep element a set distance from top of browser screen without using CSS? -


i using bootstraps modals , adding position:fixed doesnt work.

i have arrow element pointing towards modal triggering element. want arrow point trigger wherever trigger on screen.

i can enough with:

$("[data-toggle='modal']").click(function() {     triggerpos = $(this).offset().top;     $('.modal-arrow').css('top', triggerpos + "px"); });  

the problem if there long modal causes user scroll, arrow doesn't stay fixed; moves modal user scrolls.

see fiddle: https://jsfiddle.net/umv4jhlg/22/

of course have tried various arrangements css, no result.

i have tried adjusting on window scroll:

$(window).scroll(function(){   var triggerpos = $(this).offset().top;     $('.modal-arrow').css('top', triggerpos + "px");   }) 

but no results.

would know of way can keep .modal-arrow steady using jquery?

try .scrolltop()

add top position


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -