What you've described is some invalid HTML. A <p> can only contain inline
elements, so as soon as the browser sees the <div> it auto-closes the
paragraph. The rest of the text was thus never inside the p to begin with
and the browser ignores an extra </p> tag. Options:

1. Re-think whether this is really a parapraph, as it contains a div
2. Re-think whether this should really be a div, since it's inside a
paragraph. Would a span work?
3. Maybe the p should be a div and the div should be a p? (1+2=3)

- Richard

On Mon, May 19, 2008 at 7:56 AM, Carl-Erik <[EMAIL PROTECTED]> wrote:

>
> Hi, I'm new to jQuery, so forgive my ignorance if I've missed
> something trivial...
>
> I'm trying to move text enclosed in <div class="footnotes"> to the
> bottom of the page, and insert a link to the footnote in the location
> it was originally in. However, when the div is moved, the <p>-tag it
> was in gets closed, and any remaining text that was in the <p> is left
> outside. The link I insert is also outside the <p>. How can I avoid
> this?
>
> Here's my code:
>
> <script type="text/javascript">
> $(document).ready(function() {
>
>        //put all footnotes into a variable
>        var fotNoter = $(".footnote").clone();
>
>        //replace each footnote with a link to the footnote at the bottom of
> the page
>        $(".footnote").each(function(i) {
>        $(this).replaceWith("[" + "<a href='#" + i + "'>" + (i+1) + "</a>" +
> "]" );
>        });
>
>        //the div with id="footnotes" already exists at the bottom of the
> page, insert footnotes into div
>        $(fotNoter).appendTo("div#footnotes")
>
>        //print a number in front of each footnote and assign anchor id
>        $(fotNoter).each(function(j) {
>          $(this).prepend(j+1 + ") ");
>          $(this).prepend("<div id='" + j + "'>");
>          $(this).append("</div>");
>        });
> });
> </script>
>
> Instead of using replaceWith I also tried
>
> $(this).html("[" + "<a href='#" + i + "'>" + (i+1) + "</a>" + "]" );
>
> and
>
> $(this).before("[" + "<a href='#" + i + "'>" + (i+1) + "</a>" +
> "]").remove();
>
> but to no avail...
>
> Any help would be appreciated.
>
> - Carl-Erik
>

Reply via email to