SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2003
    Location
    Halifax
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Search a node returned by getElementById

    I was wondering if anyone can help me.

    I'm currently making a copy of an element id within a page using cloneNode, and want alter a link within the cloned element.

    The element I'm copying looks like this:

    Code:
    <div id="image_element">
     <a href="#" id="remove">Remove</a>
    </div>
    JS looks like this:
    Code:
    var newFields = document.getElementById('image_element').cloneNode(true);
    Anyone got any ideas how I can search within an element, as opposed to using the document.getElementById?

    TIA

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    newFields.getElementsByTagName('a');

    or

    newFields.childNodes[0];


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
  •