diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 236409b45ae31bead8f32fa2d36fc99214f31b25..992f763449da611f98bd6d72e822f5a1f0fdfcc0 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -147,7 +147,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
                     }
 
                     // add footnote markup and close this footnote
-                    $this->doc .= $footnote;
+                    $this->doc .= '<span class="content">'.$footnote.'</span>';
                     $this->doc .= '</div>'.DOKU_LF;
                 }
             }
diff --git a/lib/scripts/page.js b/lib/scripts/page.js
index a179ae2a8e45434f79a7eceea0cd87f87e937789..aadff8ecf10df59d1475b7a36119e9e5a775d916 100644
--- a/lib/scripts/page.js
+++ b/lib/scripts/page.js
@@ -83,23 +83,26 @@ dw_page = {
      *
      * @author Andreas Gohr <andi@splitbrain.org>
      * @author Chris Smith <chris@jalakai.co.uk>
+     * @author Anika Henke <anika@selfthinker.org>
      */
     footnoteDisplay: function () {
-        var content = jQuery(jQuery(this).attr('href')) // Footnote text anchor
-                      .closest('div.fn').html();
+        var $content = jQuery(jQuery(this).attr('href')) // Footnote text anchor
+                      .parent().siblings('.content').clone();
 
-        if (content === null){
+        if (!$content) {
             return;
         }
 
-        // strip the leading content anchors and their comma separators
-        content = content.replace(/((^|\s*,\s*)<sup>.*?<\/sup>)+\s*/gi, '');
-
         // prefix ids on any elements with "insitu__" to ensure they remain unique
-        content = content.replace(/\bid=(['"])([^"']+)\1/gi,'id="insitu__$2');
+        jQuery('[id]', $content).each(function(){
+            var id = jQuery(this).attr('id');
+            jQuery(this).attr('id', 'insitu__' + id);
+        });
 
+        var content = $content.html().trim();
         // now put the content into the wrapper
-        dw_page.insituPopup(this, 'insitu__fn').html(content).show().attr('aria-hidden', 'false');
+        dw_page.insituPopup(this, 'insitu__fn').html(content)
+        .show().attr('aria-hidden', 'false');
     },
 
     /**