SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    list number for ordered lists.

    is there a way of retrieving list number from an ordered list?
    Code:
    <ol>
    <li>text</li>
    <li>more</li>
    </ol>
    <script>
    document.getElementsByTagName("li")[0].onmouseover=alert(this.?????)
    </script>
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    found that I can attach the value to it first, then it can be read.
    Code:
    <ol>
    <li>m</li>
    <li>m</li>
    </ol>
    <script>
    obj=document.getElementsByTagName("li")
    for(i=0;i<obj.length;i++) {
    obj[i].value=i+1;
    obj[i].onmouseover=function() { alert(this.value )}
    }
    </script>
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


Bookmarks

Posting Permissions

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