SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Sep 2013
    0 Post(s)
    0 Thread(s)

    I want to show three elements of the list however it only shows the first

    Good night!
    I am studying the book Only JS Javascript (sitepoint).
    In Chapter 3, I'm working with DOM's.

    Code JavaScript:
    window.onload = function ()
        var listItems = document.getElementsByTagName("li");
        for (var i = 0; i < listItems.length; i++)

    It only takes the first element of the list in case Paragraph.

    Because the loop is not being done? I want the alert to show me also the other two, unordered list, and list items.
    HTML Code:
            Há três tipos de elementos neste corpo:
            <li>lista não ordenada</li>
            <li>item de lista</li>
    Thanks a lot
    Last edited by Mittineague; Sep 17, 2013 at 18:17. Reason: reformatting bbcode tags


Posting Permissions

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