I have several h2 elements on a page I'm working on and I am using waypoints.js to trigger an additional class to be added to them as they scroll into view.
Targeting each instance using ids works perfectly:
$('#one').waypoint(function(direction) {
$(#one).addClass('newClass');
}, {
offset: '80%'
})
But I am trying to avoid using id
on each instance as the content will likely be changed by the client on a regular basis so I would like to target only each individual h2
that scrolls into the viewport.
My thinking was:
$('h2').waypoint(function(direction) {
$(this).addClass('newClass');
}, {
offset: '80%'
})
but that hasn't worked. Can someone help point me in the right direction here?