diff --git a/js/misc/tabledrag.js b/js/misc/tabledrag.js
index ac41c8f6bd1b9e80f67334a266acc1512e668bb7..4900f7895bb5ed77c6a02ef0fe777865751017a2 100644
--- a/js/misc/tabledrag.js
+++ b/js/misc/tabledrag.js
@@ -121,6 +121,11 @@
      */
     this.windowHeight = 0;
 
+    /**
+     * @type {?HTMLElement}
+     */
+    this.$toggleWeightButton = null;
+
     /**
      * Check this table's settings to see if there are parent relationships in
      * this table. For efficiency, large sections of code can be skipped if we
@@ -175,10 +180,13 @@
     // Add a link before the table for users to show or hide weight columns.
     var $button = $(Drupal.theme('btn-sm', {
       'class': ['tabledrag-toggle-weight'],
+      'data-drupal-selector': ['tabledrag-toggle-weight'],
       title: Drupal.t('Re-order rows by numerical weight instead of dragging.'),
       'data-toggle': 'tooltip'
     }));
 
+    this.$toggleWeightButton = $('[data-drupal-selector="tabledrag-toggle-weight"]');
+
     $button
       .on('click', $.proxy(function (e) {
         e.preventDefault();
