Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Nested tags & getElementsByTagName

Reply
Thread Tools

Nested tags & getElementsByTagName

 
 
souporpower@gmail.com
Guest
Posts: n/a
 
      12-03-2008
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
 
Reply With Quote
 
 
 
 
SAM
Guest
Posts: n/a
 
      12-03-2008
Le 12/3/08 10:00 PM, 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>



--
sm
 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      12-03-2008
On Dec 3, 4:00*pm, "souporpo...@gmail.com" <soup_or_po...@yahoo.com>
wrote:
> 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]
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SelectNodes vs. GetElementsByTagName =?Utf-8?B?Sm9l?= ASP .Net 2 11-02-2005 04:01 PM
GetElementsByTagName: object required Ragnar Heil XML 5 04-27-2005 02:08 PM
getelementsbytagname question Danny XML 1 07-23-2004 11:10 AM
RegEx to find CFML tags nested in HTML tags Dean H. Saxe Perl 0 01-03-2004 06:11 PM
Question about Document.getElementsByTagName(String) in org.w3c.dom mynamehere Java 0 12-14-2003 09:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57