How can I check if the query string contains a q= in it using JavaScript or jQuery?
q=
Using URL:
url = new URL(window.location.href); if (url.searchParams.get('test')) { }
EDIT: if you're sad about compatibility, I'd highly suggest https://github.com/medialize/URI.js/.