I searched so much here but I didn’t find the solution to my problem, I found the solution with the select option field but I can’t use that.
So, I would like to click on one of these two links and open the link just on the button submit, I suppose it requires some jquery? Is anyone that could help?
<ul>
<li class="link-a"><a href="https://google.com">LINK A</a></li>
<li class="link-b"><a href="https://yahoo.com">LINK B</a></li>
</ul>
<button type="submit">Open clicked link</button>
2
Answers
Am not sure why you would like to do that, but here is a way to achieve your desired result, no need to jQuery in this example,
Approach:
You can achieve your desired behavior like below:
a) on click of link prevent its default behavior and then add a class to it.
b) On click of a button get the
href
of the newly added class link and open it.