Results 1 to 4 of 4
  1. #1

    can someone tell me?

    can someone tell me what the code on line 6 does? the script doesn't work without it

  2. #2
    I assume you're talking about the nextElementSibling bit? That stores the current element's next sibling element in the variable. In other words if you have:
    HTML Code:
    <li>Some content 1</li>
    <li>Some content 2</li>
    <li>Some content 3</li>
    If you select the second li, nextElementSibling refers to the third one. It's a helper method that makes DOM traversal easier. Without it, you'd have to use .parentElement, to figure out which element you're looking at, and then figure out which element is the next one, and so on.

    In most cases, you'd use this.parentElement.children[i + 1], but that won't always get you what you want.

  3. #3
    i meant this line but thanks


  4. #4
    Oh. That's like jQuery's .toggle(). If the element has the class "active", it removes it. If not, it adds it. It literally "toggles" the class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts