Skip to main content

Bug Tracker

Side navigation

#1436 closed bug (invalid)

Opened July 30, 2007 03:41AM UTC

Closed July 30, 2007 02:54PM UTC

Last modified July 31, 2007 01:52AM UTC

UNwanted addition to insertAfter()

Reported by: DK Owned by:
Priority: major Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: Cc:
Blocked by: Blocking:
Description

I am attempting to wrap a <div> around a variable number of <p> elements by using an insertAfter() after the <h2> title and an insertBefore() before the next <h2> title. Unfortunately,

$('<div id="Info_' + chapterId + '">').insertAfter($chapterTitle);

turns into

<div id="Info_chapter-1"></div>

While I believe that it may be an attempt to insert proper HTML code, I need for the following .insertBefore($chapterTitle) to handle the closing </div>, NOT the .insertAfter().

If there is another way around this, please advise.

THANKS!

Attachments (0)
Change History (2)

Changed July 30, 2007 02:54PM UTC by john comment:1

resolution: → invalid
status: newclosed

This is desired, and required. It sounds like you want to use .wrap:

  $chapterTitle.wrap('<div id="Info_' + chapterId + '"></div>');

Changed July 31, 2007 01:52AM UTC by DK comment:2

Hi John!

Thanks for your reply and suggestion but ...

My problem is that I have a Word-generated document with <h2> (or <h3>) element headers for a variable number of paragraphs (within a #content container). I want to leave the heading visible but .after() a toggle link to hide/show a <div> which would contain the trailing <p> and <ul> as well as trailing (.append()) links to hide and "back to top" THEN close the <div>. I don't believe that I can select only the immediate trailing elements (BOTH <p> and <ul> IN ORDER) up to but NOT including the next <hx> (header element) so, a wrap does not seem to be the solution to MY problem.

I've convince myself that I could .after() the <div> then move (.append()/.prepend()) the adjacent/trailing <p> OR <ul> fields in order (I don't know how to OR the F element in "E ~ F an F element preceded by an E element" to maintain the order: "E ~ (F|G)?) and .append() the toggle links (before the next <h2|h3> element) into the <div>. Since I need to iterate over the full set of <h3> elements THEN the <h2> elements (which enclose the <h3> elements), I am struggling (and fell back to my procedural/linear task education).

Any suggestions would be GREATLY appreciated.