lambolight — 2014-02-21T15:57:26-05:00 — #1
I built a site with a slider which already worked for a while but it doesn't anymore. I really regret that I didn't wrote something like a change log or a history of the file versions or something. So I changed the background pictures of the slider and some other css stuff with the caption and suddenly the slider didn't work anymore. The pictures appear, but they don't slide and those buttons for switching the pictures don't come up anymore.
I can't remember what I changed before and I don't know whats wrong now, I checked all the linkers to the jQuery files but could not find the mistake.
The project is uploaded to my webspace on http://www.phermann.tk/gera .
I hope you can help me. (I am totally expecting a dump mistake by the way.)
Thank you, Paul.
ralphm — 2014-02-21T16:26:15-05:00 — #2
Try moving this bit in red:
to the bottom of the page, just before the </body> tag:
At the moment, the script is looking for the .slider div before it has loaded, so let it load first and then call on it with JS.
lambolight — 2014-02-21T17:07:09-05:00 — #3
Great, that solves the problem. Know as you wrote it, I actually don't understand why the jQuery isn't like that instead:
The position of the code would be unimportant then.
spikez — 2014-02-21T18:34:18-05:00 — #4
That should still be at the bottom of the page for it to work right. It waits for the document to be ready before initialising.
ralphm — 2014-02-21T23:39:50-05:00 — #5
Yes, that's commonly done with jQuery if you don't place it at the end of the file. (document).ready just makes sure that the document has loaded before the script operates. I had two choices—to tell you to place the code at the bottom OR to wrap document.ready around it. But I chose the first option as it's a good idea anyway.