Hi,
I'm just learning jquery and (mostly!) enjoying it. I'm a bit
frustrated at the moment tho not understanding why multiple
appendTo()'s don't seem to work, depending on what I'm trying to
append. Here's a bit of exploratory code, called from a $.ajax()
method, that seems to be misbehaving:

function appendXmlToBody( xmlDoc ) {
        var allTitles = $(xmlDoc).find("bib/book/title");
        $("<p>hi!</p>").appendTo("body");
        $("<p>bye!</p>").appendTo("body");
        allTitles.appendTo("body");
        allTitles.appendTo("body");
}

What's I'm ending up with is this:
-----------------------------------
hi!

bye!

TCP/IP IllustratedAdvanced Programming in the Unix environmentData on
the WebThe Economics of Technology and Content for Digital TV
-----------------------------------

The last line is as expected -- it's a concatenation of the text
content of the four titles in the passed-in xml document -- but it
only appears once, and I'm expecting to see it twice. In fact, if I
call allTitles.appendTo(...) once before, and then again after the two
("<p>...") appendTo()'s and stick an alert() in the middle, the line
first appears before the two paragraphs, and then jumps, appearing
after them, the first one disappearing.

Even stranger, while I can copy/paste the "hi!" and "bye!" messages to
a text editor from my browser (firefox), trying to select and paste
the "TCP/IP ..." line actually pastes the title of the document
instead, as shown below:

file:///C:/jQuery/jqueryTest1.html

Any idea what's going on? I'm mystified.

TIA,
Howard

Reply via email to