Hi, I am new to jQuery, and it seems the very first thing I try to do
gives me problems. However, probably I am missing something so let me
ask you if you can hint me on the best way to accomplish this.

I want to transform a document with a flat structure like this

<h1>Heading 1</h1>
<p>Paragraph 1.1</p>
<p>Paragraph 1.2</p>
<h1>Heading 2</h1>
<p>Paragraph 2.1</p>
<p>Paragraph 2.2</p>

to something more hierarchical like this

<h1>Heading 1</h1>
<div>
<p>Paragraph 1.1</p>
<p>Paragraph 1.2</p>
</div>
<h1>Heading 2</h1>
<div>
<p>Paragraph 2.1</p>
<p>Paragraph 2.2</p>
</div>

The biggest problem for me is to detect where the limit between the
paragraphs (in the form of another heading) are. Unfortunately there
is nothing distinctive about the p elements (no ids, no classes, this
is generated code that I can not control)

Thanks!
/Claes

Reply via email to