diff --git a/js/sql.js b/js/sql.js
index 94cb838540eb..5dab4eb8c163 100644
--- a/js/sql.js
+++ b/js/sql.js
@@ -438,8 +438,8 @@ AJAX.registerOnload('sql.js', function () {
* @name appendToggleSpan
*/
// do not add this link more than once
- if (! $('#sqlqueryform').find('a').is('#togglequerybox')) {
- $('')
+ if (! $('#sqlqueryform').find('button').is('#togglequerybox')) {
+ $('')
.html(Messages.strHideQueryBox)
.appendTo('#sqlqueryform')
// initially hidden because at this point, nothing else
diff --git a/templates/database/search/main.twig b/templates/database/search/main.twig
index 8ef0b1b0afb3..06961801405a 100644
--- a/templates/database/search/main.twig
+++ b/templates/database/search/main.twig
@@ -81,4 +81,4 @@
{# This sqlqueryform div is used to load the delete form in the db search #}
{# Toggle query box link #}
-
+