find img, href in the html

D

David Chang

Hi I am new to javascript, and I would like to know if there's an easy to
access the picture links in an html document.

For example, there're two picture links in the following document.

<body>
.....
<a href="requestHref1"><img src="source1.gif"/></a>
....
<a href="requestHref2"><img src="source2.gif"/></a>
....
</body>


Is there a for me to retrieve information (requestHref1, source1.gif), and
(requestHref2, source2.gif) easily?

Your help is greatly appreciated!!

David
 
D

David Dorward

David said:
Hi I am new to javascript, and I would like to know if there's an easy to
access the picture links in an html document.
For example, there're two picture links in the following document.
<a href="requestHref1"><img src="source1.gif"/></a>
<a href="requestHref2"><img src="source2.gif"/></a>

XHTML is usually a poor idea, and "/" is almost certainly not what you want
in an HTML document. The alt attribute is not optional.
Is there a for me to retrieve information (requestHref1, source1.gif), and
(requestHref2, source2.gif) easily?

I'd probably loop over document.images and test the tagName of the
parentNode of each, then push it onto an array if it was an anchor.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top