How to Get Url Parameters & Values using jQuery

4 Responses

  1. Paul says:

    Thank you Karthikeyan K!

    It is useful to me.

  2. jessica says:

    search-results.html?q=physic–>i have to extract the value aggigned in ‘q’ of url…how can I get it? can anyone pls help me in this

  3. jessica says:

    assigned to q

  4. I assumed that “using jquery” means that you actually use jquery to get the query parameters. But it turns out you only put it into a plugin. Why though? Why not just use the function? It is as much as available in a named function as in $.getUrlVars(), and it is even shorter! I don’t see one good reason to put this into a jquery plugin.

    Besides, the method you used to extract the parameters is adding too much unnecessary steps.

    * You can use location.search directly, so you don’t have to search for ?.
    * If you don’t have to support IE (https://caniuse.com/#search=urlsearchparams) you can use new UrlSearchParams(location.search)

Leave a Reply

Your email address will not be published. Required fields are marked *