Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace url instead add/push in this code

Sorry guys, noob jQuery question. I found this code to change the url depending on which checkbox is selected here: Change href depending on checkboxes But I need to replace the url instead add the checkbox value to the url.

Like I'm on www.katana.com/e-bikes/ and I want to redirect to www.katana.com/product/whatever not want to stay on e-bikes subpage and continue adding the value to the url.

Thank you so much!!!

$(document).ready(function() {
    $('.checkbox').on("change", function() {
        var aHrefVals = [];

        $('.checkbox').filter(":checked").each(function() {
            aHrefVals.push($(this).val());
        });

        $("a").attr("href", aHrefVals.join(","));
    });
});
like image 581
Diego M. Avatar asked Dec 03 '25 00:12

Diego M.


1 Answers

If you do window.location.origin you will get www.katana.com . Then you can append any kind of values after the origin on checkbox change method.

like image 71
reachtokish Avatar answered Dec 04 '25 13:12

reachtokish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!