Find All Span Tags

E

Eric Cota

I have a page which has multiple span tags, I would like a javascript
function that can look at each of these span tags for me. Depending
on the what the user is doing there could be a different number of
span tags so I don't want to hard code them.

Thanks

Eric
 
M

Martin Honnen

Eric said:
I have a page which has multiple span tags, I would like a javascript
function that can look at each of these span tags for me. Depending
on the what the user is doing there could be a different number of
span tags so I don't want to hard code them.

var spans;
if (document.all) {
spans = document.all.tags('span');
}
else if (document.getElementsByTagName) {
spans = document.getElementsByTagName('span');
}
if (spans) {
// do something with it
}
 
L

Lasse Reichstein Nielsen

I have a page which has multiple span tags, I would like a javascript
function that can look at each of these span tags for me. Depending
on the what the user is doing there could be a different number of
span tags so I don't want to hard code them.

var spans = document.getElementsByTagName("span");
for (var i=0;i<spans.length;i++) {
... spans ...
}

/L
 

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

Forum statistics

Threads
474,079
Messages
2,570,573
Members
47,205
Latest member
ElwoodDurh

Latest Threads

Top