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.

Read Also:  jquery show hide multiple div onclick example

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.

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://www.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 :

Read Also:  Data auto Load While scrolling page down with jquery PHP and MySQL

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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Simple React Hello World Example
  2. Read Also:  Vue js Toggle switch Update DB field using Ajax
  3. Read Also:  Angular 5 NgSwitch Example Tutorials
  4. Read Also:  Laravel Edit DropDown Option Seleted Example
  5. Read Also:  How to get an element by id with angularjs?
  6. Read Also:  How to change date format in PHP?
  7. Read Also:  How to validate upload file size and file extension using JavaScript?
  8. Read Also:  Linux Crontab Unix Linux Command examples
  9. Read Also:  How to validate upload file size and file extension using JavaScript?
  10. Read Also:  Data auto Load While scrolling page down with jquery PHP and MySQL
CLOSEX