Reload/Refresh a Section With jQuery

Share Now

Share on facebook
Share on pinterest
Share on twitter
Share on linkedin
Share on email

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>*","");
Nahid Mahamud

Nahid Mahamud

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