Nested tags & getElementsByTagName

S

souporpower

Hi

I have in HTML nested tags like

<span id=1 class=myclass1> <span id=2 class=myclass2>....</span></
span>

In Javascript I do

nodeList=document.getElementsByTagName('span');

The nodeList does not contain the span with id=2 for some strange
reason.

Can someone please tell me how to obtain *all* of the tags in the
document regardless
of nesting?

Thanks
 
S

SAM

Le 12/3/08 10:00 PM, (e-mail address removed) a écrit :
Hi

I have in HTML nested tags like

<span id=1 class=myclass1> <span id=2 class=myclass2>....</span></
span>

In Javascript I do

nodeList=document.getElementsByTagName('span');


nodelist = document.getElementsByTagName('SPAN');
The nodeList does not contain the span with id=2 for some strange
reason.

???

id="2"
class="myclass2"

with quotes or double quotes

and then even ... an ID can't begin with a number !
Can someone please tell me how to obtain *all* of the tags in the
document regardless of nesting?

And why that for ?


Déjà qu'on se demande pourquoi il faut une class différente pour chaque
sous-span ? !

Why do you need special sub-classes for sub-spans ?

span.myClass { color: red }
span.myClass span { color: blue
span.myClass span span { color: green }

<span class="myclass"> red
<span> blue
<span> green
</span>
</span>
</span>
 
D

David Mark

Hi

I have in HTML nested tags like

<span id=1 class=myclass1> <span id=2 class=myclass2>....</span></
span>

In Javascript I do

nodeList=document.getElementsByTagName('span');

The nodeList does not contain the span with id=2 for some strange
reason.

For one, don't start ID's with number. ID's such as "1", "2", etc.
are clearly a bad idea.

[snip]
 

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

Latest Threads

Top