I have created a codepen with my code at http://codepen.io/funkysi/pen/KNayQo
The purpose of it is to cycle through a series of news articles after a specified time period and there is also a next button which allows you to manually click through them.
The code works fine but the last news article is skipped and the time period seems to vary once you start clicking next.
Thanks for any help anyone can share
I’ve take a look at your code and I think you aren’t seeing the last item in your list because in the next() function you have an if conditional which is hiding it.
Some other oddities I see:
- you are using the id of newsrow1 multiple times in your html markup, when typically you should only use it once.
- rather than set the css using jquery, you should create class to add/remove with jquery instead - examples: $(’.selected’).addClass(‘hide’); hide is class that is set to display: none;
Great advice, agree with everything you’ve said. hopefully it’s still helpful to this dude haha.