简体   繁体   中英

Jquery Waypoints .sticky Method

So I've done everything that is supposed to happen in order to initialize the jquery waypoints-sticky plugin, but it isn't working: included jquery, waypoints, and waypoints-sticky, and called the function: 在此处输入图片说明在此处输入图片说明

$('.my-element').waypoint('sticky');

However, the console reads ("The sticky method does not exist in jQuery Waypoints."):

在此处输入图片说明

What could I possibly be missing? Nothing online gives me any ideas at all. Thanks for your input!

This shortcut requires the jQuery build of Waypoints.

First, include the shortcut script after the main Waypoints script.

<script src="/path/to/lib/jquery.waypoints.min.js"></script>
<script src="/path/to/shortcuts/sticky.min.js"></script>

var sticky = new Waypoint.Sticky({
  element: $('.basic-sticky-example')[0]
})

Have you seen http://imakewebthings.com/waypoints/shortcuts/sticky-elements/ ?

Make sure that everything's getting loaded before your code executes. Try wrapping your code in a $(document).ready() call, like so:

$(document).ready(function () {
    $('.my-element').waypoint('sticky');
});

Equivalently, and slightly more concise:

$(function () {
    $('.my-element').waypoint('sticky');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM