How do you do this?
So far this is what I'm trying:
var blogHeaders = $('.coa-content h2');
$(window).scroll(function() {
blogHeaders.each(function(i) {
console.log(blogHeaders[i].offset().top);
});
})
This block of code is giving me the following:
VM941:6 Uncaught TypeError: blogHeaders[i].offset is not a function
I tried looking up "offset() for each item in loop" on here, these were the first 4 results:
VBA For Each Loop only excutes once and then stops
WordPress Custom Post Loop / alternating layout for each item
Shifting scatter points for each array for delta x
Check if array has [0][1][2] or just single item
Unfortunately, none of these answers are relevant to my question.
I googled "offset() multiple elements in loop javascript" but couldn't find any relevant answers there, either.
Is there a way to do this? Or am I taking the wrong approach here?