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


Groups > comp.lang.javascript > #26784

Question about appendChild using series of divs

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!panix3.panix.com!not-for-mail
From gcf@panix.com (Gordon)
Newsgroups comp.lang.javascript
Subject Question about appendChild using series of divs
Date 3 Feb 2015 14:24:13 -0500
Organization }"{ }"{ }"{ }"{
Lines 37
Message-ID <mar78t$fq8$1@panix3.panix.com> (permalink)
NNTP-Posting-Host panix3.panix.com
X-Trace reader1.panix.com 1422991453 14001 166.84.1.3 (3 Feb 2015 19:24:13 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Tue, 3 Feb 2015 19:24:13 +0000 (UTC)
Xref csiph.com comp.lang.javascript:26784

Show key headers only | View raw


Context: I am using the most recent Firefox browser
on a Linux (Ubuntu 14.04) box.  I am constructing a
page where, when the user clicks on a picture, 
related pictures appear under it, pushing subsequent
material down.

I have a div which I will call 'H' (for header).  
After this div, I use javascript to create and
append five divs, based on data in an object in
the program.  Each new div contains a picture and
some text.  Each of these div has a unique ID,
let us say 'A', 'B', 'C', 'D', 'E'.  In all five
cases I use appendChild to attach the div to the
'H' div.  The divs then display in the same order.
(I would think they would display in reverse order,
since they are being successively appended to 'H', not
to the last appended, but they don't.)  This action is
performed automatically when the page is first loaded,
so we observe 'H', 'A', ... ,'E', ... in the browser.

While the page is up, if the user clicks on a link within
one of the five divs, say 'C', another set of divs is similarly
created, let us say 'c1', 'c2', 'c3', ....  These I append
to div 'C'.  I want them to appear below 'C' and before 'D',
but instead they display below 'E'.

My questions are (1) Why, if appending after 'H' works
as I expect, don't the other appendChild calls? and 
(2) How can I get the result I want?  Note: I don't 
want to do the work of locating these items on the
page by numerical coordinates, I want the browser to 
do that work, so the divs will respond to possible
changes in the size for foregoing material.  If
possible.

Thanks for any help or suggestions you can give.

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


Thread

Question about appendChild using series of divs gcf@panix.com (Gordon) - 2015-02-03 14:24 -0500
  Re: Question about appendChild using series of divs JJ <jj4public@vfemail.net> - 2015-02-04 07:10 +0700
    Re: Question about appendChild using series of divs gcf@panix.com (Gordon) - 2015-02-05 18:02 +0000
  Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-04 14:23 +0100
    Re: Question about appendChild using series of divs Tim Streater <timstreater@greenbee.net> - 2015-02-04 13:34 +0000
      Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-04 15:12 +0100
    Re: Question about appendChild using series of divs gcf@panix.com (Gordon) - 2015-02-05 17:59 +0000
      Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-05 19:21 +0100
        Re: Question about appendChild using series of divs John Harris <niam@jghnorth.org.uk.invalid> - 2015-02-05 19:36 +0000
          Re: Question about appendChild using series of divs Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-07 12:07 +0100
            Re: Question about appendChild using series of divs John Harris <niam@jghnorth.org.uk.invalid> - 2015-02-07 15:20 +0000

csiph-web