Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Event Model

_For instructions on how to run the tests, check here

Task 1

Create a function that takes an id or DOM element and:

  • If an id is provided, select the element
  • Finds all elements with class button or content within the provided element
    • Change the content of all .button elements with "hide"
  • When a .button is clicked:
    • Find the topmost .content element, that is before another .button and:
      • If the .content is visible:
        • Hide the .content
        • Change the content of the .button to "show"
      • If the .content is hidden:
        • Show the .content
        • Change the content of the .button to "hide"
      • If there isn't a .content element after the clicked .button and before other .button, do nothing
  • Throws if:
    • The provided DOM element is non-existant
    • The id is neither a string nor a DOM element
You can’t perform that action at this time.