Reload/Refresh a Section With jQuery

Share Now

Sample code for getting url

jQuery(document).on('ready', function() {
 var variant = $('select.product-single__variants :selected').val();
 console.log( variant );
 var loc = window.location;
 var origin = location.origin;
 var pathname = location.pathname;
 var finalUrl = origin + pathname + "?variant=" + variant;

 //updating URL
 history.pushState({}, null, finalUrl);
});

Sample code for reload a section

$(".product__price-and-badge .product__price").load(finalUrl+" .product__price-and-badge .product__price>*","");
Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert