Connecting Tech Pros Worldwide Help | Site Map

getting the id of a given child, doesnt work in ff but does in safari

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 15th, 2007, 03:35 PM
libsfan01
Guest
 
Posts: n/a
Default getting the id of a given child, doesnt work in ff but does in safari

in firefox the following alert does not get created from my function:

ch = container1.childNodes(0).id;
alert(ch)

can anyone tell why this might not work in firefox but does in safari?

thanks

marc


  #2  
Old May 15th, 2007, 04:05 PM
RobG
Guest
 
Posts: n/a
Default Re: getting the id of a given child, doesnt work in ff but does insafari

libsfan01 wrote:
Quote:
in firefox the following alert does not get created from my function:
>
ch = container1.childNodes(0).id;
childNodes is a list, not a function - some browsers are confused about
that:

var ch = container1.childNodes[0].id;


--
Rob
"We shall not cease from exploration, and the end of all our
exploring will be to arrive where we started and know the
place for the first time." -- T. S. Eliot
  #3  
Old May 15th, 2007, 04:15 PM
Geoffrey Summerhayes
Guest
 
Posts: n/a
Default Re: getting the id of a given child, doesnt work in ff but does in safari

On May 15, 11:31 am, libsfan01 <mcyi2...@googlemail.comwrote:
Quote:
in firefox the following alert does not get created from my function:
>
ch = container1.childNodes(0).id;
alert(ch)
>
can anyone tell why this might not work in firefox but does in safari?
Are you getting an error in the console?

---
Geoff

  #4  
Old May 15th, 2007, 04:55 PM
ASM
Guest
 
Posts: n/a
Default Re: getting the id of a given child, doesnt work in ff but does insafari

Geoffrey Summerhayes a écrit :
Quote:
On May 15, 11:31 am, libsfan01 <mcyi2...@googlemail.comwrote:
Quote:
>in firefox the following alert does not get created from my function:
>>
>ch = container1.childNodes(0).id;
>alert(ch)
>>
>can anyone tell why this might not work in firefox but does in safari?
Why it could work in Safary I don't know,
but why it doesn't work in FF :
because the first chidNode in FF is an invisible text node (without id)
and anyway ... it is :

ch = container1.childNodes[0];
Quote:
Are you getting an error in the console?
He can also have a look in Firefox's DOM inspector ( #text )

test :
======
ch = container1.childNodes[0];
alert(ch.nodeName);

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
  #5  
Old May 15th, 2007, 05:45 PM
Geoffrey Summerhayes
Guest
 
Posts: n/a
Default Re: getting the id of a given child, doesnt work in ff but does in safari

On May 15, 12:45 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
Quote:
Geoffrey Summerhayes a écrit :
>
Quote:
On May 15, 11:31 am, libsfan01 <mcyi2...@googlemail.comwrote:
Quote:
in firefox the following alert does not get created from my function:
>
Quote:
Quote:
ch = container1.childNodes(0).id;
alert(ch)
>
Quote:
Quote:
can anyone tell why this might not work in firefox but does in safari?
>
Why it could work in Safary I don't know,
but why it doesn't work in FF :
because the first chidNode in FF is an invisible text node (without id)
and anyway ... it is :
>
ch = container1.childNodes[0];
Actually the absence of id wouldn't cause a problem for this,
FF would show 'undefined' in the alert box. Round brackets
as opposed to square definitely are the culprit.
Quote:
Quote:
Are you getting an error in the console?
>
He can also have a look in Firefox's DOM inspector ( #text )
Depends a lot on what container1 is, a text node isn't always
the first child.

But it's always a good idea to learn to use the tools that are
there to make the job easier.

---
Geoff

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.