Creating a Hierarchy

Creating a Hierarchy

I am using the following code to create a (nodelist? [of children]) of "genText"-class divs that are appended to a (parent?) "classContainer" div:
  1. $(".classContainer")
  2.       .append($("<div class=genText " +
  3.             "firstWord=" + firstWord + " " +
  4.             "taxYear =" + taxYear + " " + ">" + currentLine + " | " + lColor + "</div>")
  5.       .css({ color: lColor }));

After I have my wrapped set of [something, definitely not Array Elements...jQuery Objects?], then I would like to make changes to some of the individual elements. For that purpose, I have the next bit of code:

  1. var updatedWrappedSet = $(".classContainer > .genText").each(function() {
  2. var lineWordArray = this.innerText.reduceWhiteSpace().split(" ");
  3. var firstWord = lineWordArray[0];
  4. var secndWord = lineWordArray[1];
  5. if ( (firstWord == "PHU1") && (secndWord.indexOf("DTE") != -1) ||
  6. (firstWord.indexOf("+++") != -1) && (secndWord.indexOf("+++") != -1) ||
  7. (firstWord.indexOf("TRANS") != -1) && (secndWord.indexOf("RPD") != -1) ||
  8. (firstWord.indexOf("EVNT-") != -1) && (1==1)) {
  9. if ((firstWord == "PHU1") && (secndWord.indexOf("DTE") != -1)) {
  10.       // top-level node.
  11.       // Great grandparent of the innerMost child (remains a "genText" div sibling)
  12. } else if ((firstWord.indexOf("+++") != -1) && (secndWord.indexOf("+++") != -1)) {
  13.       // demote this genText div by one level.
  14.       // I would like this to be a grandparent node of the innerMost child
  15. } else if ((firstWord.indexOf("TRANS") != -1) && (secndWord.indexOf("RPD") != -1)) {
  16.       // demote this genText div by two levels.
  17.       // I would like this to be a parent node of the innerMost child
  18. } else if ((firstWord.indexOf("EVNT-") != -1) && (1==1))) {
  19.       // demote this genText div node by three levels
  20.       // innerMost child
  21. }
  22. } // end if
How do I create an updatedWrappedSet that returns a [restructured] div like the one above?
Thanks