diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js
index 2bf708e..9427a9f 100644
--- a/core/misc/tableselect.js
+++ b/core/misc/tableselect.js
@@ -21,14 +21,16 @@ Drupal.tableSelect = function () {
   var strings = { 'selectAll': Drupal.t('Select all rows in this table'), 'selectNone': Drupal.t('Deselect all rows in this table') };
   var updateSelectAll = function (state) {
     // Update table's select-all checkbox (and sticky header's if available).
-    $table.prev('table.sticky-header').andSelf().find('th.select-all input:checkbox').each(function() {
+    $table.prev('table.sticky-header').andSelf().add($selectAll.find('input:checkbox')).each(function() {
       $(this).attr('title', state ? strings.selectNone : strings.selectAll);
       this.checked = state;
     });
   };
 
   // Find all <th> with class select-all, and insert the check all checkbox.
-  $table.find('th.select-all').prepend($('<input type="checkbox" class="form-checkbox" />').attr('title', strings.selectAll)).click(function (event) {
+  var $selectAll = $('<label><input type="checkbox" class="form-checkbox"/> ' + strings.selectAll + '</label>');
+  $selectAll.find('input').attr('title', strings.selectAll);
+  $selectAll.click(function (event) {
     if ($(event.target).is('input:checkbox')) {
       // Loop through all checkboxes and set their state to the select all checkbox' state.
       checkboxes.each(function () {
@@ -40,6 +42,7 @@ Drupal.tableSelect = function () {
       updateSelectAll(event.target.checked);
     }
   });
+  $table.before($selectAll);
 
   // For each of the checkboxes within the table that are not disabled.
   checkboxes = $table.find('td input:checkbox:enabled').click(function (e) {
