diff --git a/core/modules/field/modules/text/text.js b/core/modules/field/modules/text/text.js
index 8527355061e..01a49a738af 100644
--- a/core/modules/field/modules/text/text.js
+++ b/core/modules/field/modules/text/text.js
@@ -6,41 +6,41 @@
 Drupal.behaviors.textSummary = {
   attach: function (context, settings) {
     $(context).find('.text-summary').once('text-summary', function () {
-      var $widget = $(this).closest('div.field-type-text-with-summary');
-      var $summaries = $widget.find('div.text-summary-wrapper');
+      var $widget = $(this).closest('.text-format-wrapper');
 
-      $summaries.once('text-summary-wrapper').each(function(index) {
-        var $summary = $(this);
-        var $summaryLabel = $summary.find('label');
-        var $full = $widget.find('.text-full').eq(index).closest('.form-item');
-        var $fullLabel = $full.find('label');
+      var $summary = $widget.find('.text-summary-wrapper');
+      var $summaryLabel = $summary.find('label');
+      var $full = $widget.find('.text-full').closest('.form-item');
+      var $fullLabel = $full.find('label');
 
-        // Create a placeholder label when the field cardinality is
-        // unlimited or greater than 1.
-        if ($fullLabel.length == 0) {
-          $fullLabel = $('<label></label>').prependTo($full);
+      // Create a placeholder label when the field cardinality is greater
+      // than 1.
+      if ($fullLabel.length === 0) {
+        $fullLabel = $('<label></label>').prependTo($full);
+      }
+
+      // Set up the edit/hide summary link.
+      var $link = $('<span class="field-edit-link">(<a class="link-edit-summary" href="#nogo">' + Drupal.t('Hide summary') + '</a>)</span>');
+      var $a = $link.find('a');
+      $link.toggle(
+        function (e) {
+          e.preventDefault();
+          $summary.hide();
+          $a.html(Drupal.t('Edit summary'));
+          $link.appendTo($fullLabel);
+        },
+        function (e) {
+          e.preventDefault();
+          $summary.show();
+          $a.html(Drupal.t('Hide summary'));
+          $link.appendTo($summaryLabel);
         }
+      ).appendTo($summaryLabel);
 
-        // Setup the edit/hide summary link.
-        var $link = $('<span class="field-edit-link">(<a class="link-edit-summary" href="#">' + Drupal.t('Hide summary') + '</a>)</span>').toggle(
-          function () {
-            $summary.hide();
-            $(this).find('a').html(Drupal.t('Edit summary')).end().appendTo($fullLabel);
-            return false;
-          },
-          function () {
-            $summary.show();
-            $(this).find('a').html(Drupal.t('Hide summary')).end().appendTo($summaryLabel);
-            return false;
-          }
-        ).appendTo($summaryLabel);
-
-        // If no summary is set, hide the summary field.
-        if ($(this).find('.text-summary').val() == '') {
-          $link.click();
-        }
-        return;
-      });
+      // If no summary is set, hide the summary field.
+      if ($widget.find('.text-summary').val() === '') {
+        $link.click();
+      }
     });
   }
 };