Skip to content

Instantly share code, notes, and snippets.

@JuliaKiselyova
Created November 28, 2023 10:32
Show Gist options
  • Select an option

  • Save JuliaKiselyova/c7c3c0177ec5b63cd19f1de4349818c6 to your computer and use it in GitHub Desktop.

Select an option

Save JuliaKiselyova/c7c3c0177ec5b63cd19f1de4349818c6 to your computer and use it in GitHub Desktop.
Auto focus on typing in the search widget
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