Get URL Parameter Values With jQuery - Getjs

File Size: 5.42 KB
Views Total: 936
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Get URL Parameter Values With jQuery - Getjs

Getjs is a jQuery plugin that retrieves parameters (also called query string) and their values from a URL you provide.

See Also:

How to use it:

1. Download and import the jquery-getjs.js plugin.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/build/jquery-getjs.js"></script>

2. Get the value of the given parameter from the current page URL.
const myValue = $.getjs("site");
// returns
myValue = "jqueryscript"

3. Execute a callback if the parameter exits.

$.getjs("site", function(value) {
  alert("Your site is "+value);

4. Execute a callback if no matched parameter exits.

$.getjs("surname", function(value) {
  alert("Your surname is "+value);
}, function() {
  alert("You need to provide a surname");

This awesome jQuery plugin is developed by amprogramacion. For more Advanced Usages, please check the demo page or visit the official website.