Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16535

firstChild Problem

From "Mel Smith" <med_cutout_syntel@aol.com>
Newsgroups comp.lang.javascript
Subject firstChild Problem
Date 2012-10-10 11:20 -0600
Message-ID <adlp3qFhpnlU1@mid.individual.net> (permalink)

Show all headers | View raw


Hi:

    I'm trying to set a value into a <span> element which on loading is 
empty.

    This causes a FF error.

    If I beging with an non-empty value in the span element, there is no 
problem.

    But if I (in a JS function try to initialize the value in the <span>, FF 
says the firstChile value is null !  (I *know* that it is (or *may*) be 
empty, but wish to init it anyway.

    What stupid thing am I assuming here ??

Thanks !

-- Mel Smith


***************************
myjsfunc() {
..
// I'm trying to initialize a text node with the word 'Searching'
// But when I try to, then,
// the next line results in a FireFox error: 'srchtxt.firstChild' is null

// Here is the line that results in the error:

srchtxt.firstChild.nodeValue = "Searching ...";

// Yet if I intentionally place a 'searching ...' string
// in the <span> on the original page, it works correctly, and if I then
// set the nodeValue later to ""  (i.e., empty string), and re-enter my 
function,
// there is no error ?
}


<body>
<div id="somediv">
<span id="srchtxt"></span>
</div>
</body>

*********************************** 

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

firstChild Problem "Mel Smith" <med_cutout_syntel@aol.com> - 2012-10-10 11:20 -0600
  Re: firstChild Problem -- Correction "Mel Smith" <med_cutout_syntel@aol.com> - 2012-10-10 11:35 -0600
    Re: firstChild Problem -- Correction "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-10-10 20:42 +0300
  Re: firstChild Problem Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-10 17:40 +0000
  Re: firstChild Problem Matt McDonald <matt@fortybelow.ca> - 2012-10-10 13:56 -0400
    Re: firstChild Problem "Mel Smith" <med_cutout_syntel@aol.com> - 2012-10-10 12:13 -0600

csiph-web