Skip to content Skip to sidebar Skip to footer

How Replace Query String Values Using JQuery?

I have a problem , my original URL looks like this: test.com/?manufacturer=0&body-style=0&min-price=270%2C000&max-price=780%2C000 As you can see, the min-price and max

Solution 1:

use replace function like this :

  function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
               results = regex.exec(location.search);
            return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }

     var min_price_original=getParameterByName('min-price').replace('%2C','');
     var max_price_original=getParameterByName('max-price').replace('%2C','');

Post a Comment for "How Replace Query String Values Using JQuery?"