Connecting Tech Pros Worldwide Forums | Help | Site Map

list of links between <div></div>

Zarkas
Guest
 
Posts: n/a
#1: Jul 20 '05
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

Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#2: Jul 20 '05

re: list of links between <div></div>


zarkas@hotmail.com (Zarkas) writes:
[color=blue]
> 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..[/color]

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 - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Zarkas
Guest
 
Posts: n/a
#3: Jul 20 '05

re: list of links between <div></div>


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



Lasse Reichstein Nielsen <lrn@hotpop.com> wrote in message news:<r7y88qof.fsf@hotpop.com>...[color=blue]
> zarkas@hotmail.com (Zarkas) writes:
>[color=green]
> > 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..[/color]
>
> 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[/color]
Closed Thread