I got this HTML with several unordered lists.
<ul>
<h3>Staff</h3>
<li><a href="?staff=Mike">Mike</a></li>
<li><a href="?staff=John">John</a></li>
<li><a href="?staff=Kyle">Kyle</a></li>
</ul>
<ul>
<h3>Category</h3>
<li><a href="?category=Food">Food</a></li>
<li><a href="?category=Sports">Sports</a></li>
<li><a href="?category=News">News</a></li>
<li><a href="?category=Games">Games</a></li>
<li><a href="?category=GIFs">GIFs</a></li>
</ul>
As can be seen, all of them contains with params values in each of its hrefs. My question is: using Javascript, how can I append a new value in a param in the href if one of them are actives in the URL.
IE:
The URL is www.site.com/?category=Food.
So the lists should be valued as:
<ul>
<h3>Staff</h3>
<li><a href="?category=Food&staff=Mike">Mike</a></li>
<li><a href="?category=Food&staff=John">John</a></li>
<li><a href="?category=Food&staff=Kyle">Kyle</a></li>
</ul>
<ul>
<h3>Category</h3>
<li><a href="?category=Food">Food</a></li>
<li><a href="?category=Food,Sports">Sports</a></li>
<li><a href="?category=Food,News">News</a></li>
<li><a href="?category=Food,Games">Games</a></li>
<li><a href="?category=Food,GIFs">GIFs</a></li>
</ul>
question from:
https://stackoverflow.com/questions/65930678/adding-more-than-one-get-value-in-the-href 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…