Created
November 28, 2023 10:32
-
-
Save JuliaKiselyova/c7c3c0177ec5b63cd19f1de4349818c6 to your computer and use it in GitHub Desktop.
Auto focus on typing in the search widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.addEventListener("DOMContentLoaded", function() { | |
| var searchInput = document.querySelector(".jet-ajax-search__field"); | |
| if (searchInput) { | |
| searchInput.focus(); | |
| var inputEvent = new Event('input', { bubbles: true }); | |
| searchInput.dispatchEvent(inputEvent); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment