SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getElementById and then getElementById again?

    var staticNote = document.getElementById(currLevel+"-"+currTab+"-"+noteId+"-display");

    var getContentOnly = staticNote.getElementById('noteContentHolder');

    Can you do the above? get and element by Id and then get another element by id within the first returned set?

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
        if (staticNote.hasChildNodes())
        {
           var children = staticNote.childNodes;
    
           for (var i = 0; i < children.length; i++) 
           {
              if (children[i].id ==  'noteContentHolder')
              {
    
    
              }
           }
    
        }

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    getElementById is a method of the document object only, so no you can't do that.

    Since IDs must be unique per document, you should be able to do:
    var staticNote = document.getElementById(currLevel+"-"+currTab+"-"+noteId+"-display");
    var getContentOnly = document.getElementById('noteContentHolder');


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
  •