diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 1eb1556a25d..b3ad4774091 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -115,7 +115,7 @@
case "s":
case "S":
ev.preventDefault();
- $(".search-input").focus();
+ focusSearchBar()
break;
case "?":
@@ -960,5 +960,5 @@
// Sets the focus on the search bar at the top of the page
function focusSearchBar() {
- document.getElementsByName('search')[0].focus();
+ $('.search-input').focus();
}