Extracting data from tags and attributes

U

undbund

Hi, i am trying to learn javascript, so need help with the following.
I want to extract images/image-1.jpg from the block of code below.
How can I do this, any help or tutorial will be useful.

<div id="imageContainer">
<img id="lightboxImage" style="opacity: 0.999999;" src="images/
image-1.jpg"/>
<div id="hoverNav" style="">
<a id="prevLink" href="#" style="display: none; height: 338px;"/>
<a id="nextLink" href="#" style="height: 338px;"/>
</div>
<div id="loading" style="display: none;">
<a id="loadingLink" href="#">
<img src="images/loading.gif"/>
</a>
</div>
</div>

Thanks for all your help,
undbund
 
R

RobG

Hi, i am trying to learn javascript, so need help with the following.
I want to extract images/image-1.jpg from the block of code below.
How can I do this, any help or tutorial will be useful.

<div id="imageContainer">
<img id="lightboxImage" style="opacity: 0.999999;" src="images/
image-1.jpg"/>

To get a reference to the image element, use:

var img = document.getElementById('lightboxImage');

to see the value of the src attribute:

alert(img.src);

Don't forget feature detection:
<URL: http://developer.mozilla.org/en/doc...veloping_Cross_Browser.2FCross_Platform_Pages
The clj FAQ has some very useful tips:
<URL: http://www.jibbering.com/faq/ >

Incidentally, it is considered more appropriate to use HTML 4 strict
on the web, in which case your markup should look like HTML, not
XHTML.
 

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
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top