.each function?

.each function?

Hi all!

I've received a complex task that I'm not able to answer. Hope you guys can help me!

Task:
You have a hypothesis that changing the order of the "Add to Wish List" and "Book Now" elements will increase conversions. Write the JavaScript needed to swap the 2 elements for every trip listed on the page when the "Change Order" button is clicked.

Hint: You may want to write an each function to have this work properly. Make sure that you only have 1 "Add to Wish List" element and 1 "Book Now" element under each trip.

HTML document:

  1. <h1>This is a Header</h1>
  2.     <button id="changeOrder" type="button">Change Order</button>
  3. <div id="Paris">
  4. <h2>Book a trip to Paris</h2>
  5.     <div id="Paris_wish" class="wish_list">Add to Wish List</div>
  6.     <div id="Paris_book" class="book_now">Book Now!</div>
  7. </div>
  8. <div id="London">
  9. <h2>Book a trip to London</h2>
  10.     <div id="London_wish" class="wish_list">Add to Wish List</div>
  11.     <div id="London_book" class="book_now">Book Now!</div>
  12. </div>

  13. $(function() {
  14.     $("#changeOrder").click(function() {
  15.         // ADD YOUR CODE HERE
  16.         
  17.     });
  18. });


Thanks in advanced!

Jonathan