Home › Forums › Other › Jquary navbar change when section (DIV) is view-able in window › Reply To: Jquary navbar change when section (DIV) is view-able in window
March 6, 2018 at 5:58 pm
#267989
Participant
Could you maybe add the HTML and relevant CSS as well so the code is fully working? That way I might be able to figure out why the coordinates are off. It should normally work as expected…
Although jQuery is also JavaScript, it has its own methods that can’t be directly used back and forth on the elements. The correct way to write the syntax for getBoundingClientRect
while using it on a JQuery object is like this:
var top1 = $('.header')[0].getBoundingClientRect().top;
Where $('.header')[0]
replaces element
.