Home » Get Query String Parameters from URL using JQuery

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:  Set dynamically Next Page Url Using JQuery DataTable

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:  Simple Ajax Upload image using jQuery PHP

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:  how to upload image in php and store in database and folder?
  2. Read Also:  CodeIgniter JQuery Ajax Request Example
  3. Read Also:  jQuery AJAX laravel 6 Delete Data from database
  4. Read Also:  Pure JavaScript Star Rating Example
  5. Read Also:  Data Tables State save local storage in jQuery
  6. Read Also:  How to Define and Call a Function in javascript?
  7. Read Also:  how to trigger a file download in javascript?
  8. Read Also:  PHP JQuery Ajax Request POST Data
  9. Read Also:  How to Define and Call a Function in javascript?
  10. Read Also:  Pure JavaScript Star Rating Example

Leave a Comment

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