diff --git misc/collapse.js misc/collapse.js
index 4e9f9ca..48877ef 100644
--- misc/collapse.js
+++ misc/collapse.js
@@ -83,7 +83,14 @@ Drupal.behaviors.collapse = {
         .append(summary)
         .after(
           $('<div class="fieldset-wrapper"></div>')
-            .append(fieldset.children(':not(legend):not(.action)'))
+            .append(fieldset.contents().filter(function() {
+              // If this is an HTML element, check to make sure it should be
+              // added to the div. Add all other nodes to the div.
+              if (this.nodeType == 1) {
+                return $(this).is(':not(legend):not(.action)');
+              }
+              return true;
+            }))
         );
     });
   }
