Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

jquery: store urls into an array and open them using .click(); function with next, previous, random controls

My Exlanation of what I am trying to do

  1. create an empty class in HTML like so:
    <div class="resources"></div>

  2. create an array of URLs in JAVASCRIPT/JQUERY and store them within .resources class

  3. create prev , random , next buttons in HTML

  4. random button when clicked opens random URL from array i.e.: $(array[random]).click();

  5. next button when clicked opens next URL from array i.e.: $(array[+1]).click();

  6. prev button when clicked opens previous URL from array i.e.: $(array[-1]).click();

MUSTS: urls must be opened with: click(); function: like so: $(array[0]).click();

fiddle to make it clearer: view http://jsfiddle.net/2my5mmno/

thank you for your time

2 Answers

I'm not sure how it's going to work for you. What should happen when you click on next for example? Link to another page? Do you mean something like this?: example link

yes, something like that. I solved it already though ;)