list of links between <div></div>

Discussion in 'Javascript' started by Zarkas, Jan 10, 2004.

  1. Zarkas

    Zarkas Guest

    Hi' there

    Could someone tell me how to access the links for part of my page?
    (between a div tag)
    Like document.links but only for a part of the document..

    been messing around with it for some hours without luck.

    thanks,
    -Mic
    Zarkas, Jan 10, 2004
    #1
    1. Advertising

  2. (Zarkas) writes:

    > Hi' there
    >
    > Could someone tell me how to access the links for part of my page?
    > (between a div tag)
    > Like document.links but only for a part of the document..


    Not exactly like it (document.links also contain area elements), but
    close:

    var myDiv = document.getElementById("divId");
    var divLinks = myDiv.getElementsByTagName("a");

    You should check that the elements of the collection in divLinks have
    a href. It collects all a-elements, also those without href attributes,
    where document.links only contain the ones with an href attribute.

    /L
    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Jan 10, 2004
    #2
    1. Advertising

  3. Zarkas

    Zarkas Guest

    Just what I was looking for.. worked like a charm, thanks.



    Lasse Reichstein Nielsen <> wrote in message news:<>...
    > (Zarkas) writes:
    >
    > > Hi' there
    > >
    > > Could someone tell me how to access the links for part of my page?
    > > (between a div tag)
    > > Like document.links but only for a part of the document..

    >
    > Not exactly like it (document.links also contain area elements), but
    > close:
    >
    > var myDiv = document.getElementById("divId");
    > var divLinks = myDiv.getElementsByTagName("a");
    >
    > You should check that the elements of the collection in divLinks have
    > a href. It collects all a-elements, also those without href attributes,
    > where document.links only contain the ones with an href attribute.
    >
    > /L
    Zarkas, Jan 10, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. roopa
    Replies:
    6
    Views:
    737
    Jerry Coffin
    Aug 27, 2004
  2. K Viltersten

    <div ... /> and <div ...></div>

    K Viltersten, Mar 30, 2009, in forum: ASP .Net
    Replies:
    4
    Views:
    738
  3. sean_n
    Replies:
    2
    Views:
    112
    Inder Hooda
    May 5, 2008
  4. Dwayne Madsen

    Q: Div A inside Div B is larger than Div B

    Dwayne Madsen, Jun 1, 2005, in forum: Javascript
    Replies:
    1
    Views:
    182
    David Dorward
    Jun 1, 2005
  5. Replies:
    5
    Views:
    158
    Laser Lips
    Jul 31, 2008
Loading...

Share This Page