Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other AnythingSlider – Cannot reproduce results from CodePen. Re: AnythingSlider – Cannot reproduce results from CodePen.

#122985
Mottie
Member

Hi mdroidian!

The problem is that the `$(‘#slide-jump’).click()` code was incorrectly added INSIDE of the AnythingSlider plugin code. This is only a problem because your `js.js` file is loaded and executed in the `` of your page, which happens before the `` has completed loading. So `#slide-jump` and `#slide-jump1` don’t exist yet.

So you have two options:

1) Remove the code from inside of the AnythingSlider code, then move it to where AnythingSlider is initialized (preferred method):

$(function(){
$(‘#slider’).anythingSlider(); // add any non-default options here

$(“#slide-jump”).click(function(e){ $(‘#slider’).anythingSlider(2); e.preventDefault(); });
$(“#slide-jump1”).click(function(e){ $(‘#slider’).anythingSlider(1); e.preventDefault(); });
});

2) Move where you load the `js.js` file to the bottom of the page. This method is suggested by the authors of [HTML5 boilerplate](http://html5boilerplate.com/). It would work just like this, but you still really need to move the code out from inside the plugin code.