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


Groups > comp.lang.javascript > #16537

Re: firstChild Problem

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: firstChild Problem
Date 2012-10-10 17:40 +0000
Organization A noiseless patient Spider
Message-ID <k54bue$5t0$3@dont-email.me> (permalink)
References <adlp3qFhpnlU1@mid.individual.net>

Show all headers | View raw


On Wed, 10 Oct 2012 11:20:53 -0600, Mel Smith wrote:

> ***************************
> 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 ...";

Assuming: <span id="srchtxt"></span>

// takes one param, expects boolean value
function displaySearchingText( searching ) {

var theSpan = document.getElementById( "srchtxt" );

while ( theSpan.childNodes.length != 0 )
  theSpan.removeChild( theSpan.childNodes.item( 0 ) );

if ( searching )
  theSpan.appendChild( document.createTextNode( "Searching ..." ) );

}

Rgds

Denis McMahon

Back to comp.lang.javascript | Previous | Next — Previous in thread | 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