user8331511
user8331511

Reputation:

Waypoint not calling on section

I'm currently using jQuery waypoint trying to trigger a waypoint on a section, however, it doesn't work. Not sure if this is due to localhost or what.

My current code is

$('.howDoesItWork').waypoint(function() {
    $(".header").css({
      background: 'yellow'
    });
  }, { offset: 1000 });

this doesn't work, however, if I do

$('body').waypoint(function() {
    $(".howDoesItWork .header").css({
      background: 'yellow'
    });
  }, { offset: 1000 });

it works.

I have the code wrapped around $(document).ready(function() so I don't see that being the issue.

Upvotes: 0

Views: 290

Answers (2)

George
George

Reputation: 41

If you're using jquery, just wrap the entire script inside $(document).ready() like this;

$(document).ready(function() {
 ...
 $('selector').waypoint()
})

It worked for me

Upvotes: 1

Najib TAHAR-BERRABAH
Najib TAHAR-BERRABAH

Reputation: 71

http://imakewebthings.com/waypoints/

I use Waypoint like this :

var infoPage = document.querySelector('.infoPage');
var waypoint = new Waypoint({
  element: infoPage,
  handler: function() {
    infoPage.classList.add('infoReset')
  },
});

Maybe this will help you.

Upvotes: 1

Related Questions