My main requirement is to generate a URL by clicking on the relevant button. For example If I click on the green and red button then it should append &_colour=green%2Cred in the url and similar for Gender's button after saving and getting values from localStorage.
example.com/product-category/glasses/?_gender=women%2Cmen&_colour=green%2Cred
<div class="main-section">
<div class="section">
<button data-gender="men">Men</button>
<button data-gender="women">Women</button>
</div>
<div class="section">
<button data-colour="green">green</button>
<button data-colour="red">Red</button>
</div>
</div>
jQuery('.section button').click(function(e){
e.preventDefault();
var gender = jQuery(this).data("gender");
var colour = jQuery(this).data("colour");
localStorage.setItem("gender", gender);
var x = localStorage.getItem("gender");
console.log(x);
});
The question is how to save multiple values against the same type and retrieve the values to create the url.
Thanks in Advance.