Skip to main content

Get Query String Parameters from URL using JQuery

Today, We want to share with you Get Query String Parameters from URL using JQuery.In this post we will show you example for remove query string, hear for remove query string from URL JavaScript we will give you demo and example for implement.In this post, we will learn about How to Get Query String Parameters from URL using JavaScript with an example.

Get Query String Parameters from URL using JQuery

There are the Following The simple About Get Query String Parameters from URL using JQuery Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery remove query string parameter from address bar, so the remove query string from URL using JQuery for this example is following below.

Also Read :  Vue js 2 Autocomplete Component

Example 1: Remove Query String with jQuery

$(document).ready(function(){
	var get_url_query = window.location.toString();
	if (get_url_query.indexOf("?") > 0) {
	    var live_my_url = get_url_query.substring(0, get_url_query.indexOf("?"));
	    window.history.replaceState({}, document.title, live_my_url);
	}
});

Example 2: jQuery remove query string parameter from url

$(document).ready(function(){
	var get_url_query = window.location.toString();
	if (get_url_query.indexOf("?") > 0) {
	    var live_my_url = get_url_query.substring(0, get_url_query.indexOf("?"));
	    window.history.replaceState({}, document.title, live_my_url);
	}
});

Example 3: jquery remove query string parameter from address bar

var live_my_url = location.protocol + "//" + location.host + location.pathname;
window.history.replaceState({}, document.title, live_my_url);

Example 4: Removing Query String

Removing Query String from URL by using jquery

var live_my_url = window.location.href;
var first = live_my_url.indexOf("?");
var second =  live_my_url.substring(a);
var third = live_my_url.replace(b,"");
live_my_url = third;

Example 5: Get Query String Parameters from URL using JavaScript

Assume that the URL is

https://pakainfo.com/index.php?type=member&id=9898

Get Query String Parameters
var queryString = location.search;
// ?type=member&id=9898

Get Query String Parameter Value
var live_my_url = new URLSearchParams(location.search);

live_my_url.has('type');  // true
live_my_url.get('id');    // 9898
live_my_url.getAll('id'); // ["9898"]
live_my_url.toString();   // type=member&id=9898

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read :  Vuejs check if Element Exists Example

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Get Query String Parameters from URL using JQuery.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Web Developer

Hi, I’m Web developer, PHP developer.Pakainfo.com is the most popular Programming & Web Development blog. Our mission is to provide the best online resources on programming and web development.Any visitors of this site are free to browse our tutorials, live demos, Examples and download scripts.If you have a project that you want to get started, launch quickly, contact me. Email : [email protected]