i need to open two links when a button is clicked in the html page. I figured it as by calling onclick function and creating anchor tag using createElement in Javascript. But how to include another link?? Is there a way to give a href in button tag??
To add a link to a button in HTML, the <a> element is used to define a link and href is used to define the link address.
The usage of the HTML <a> elementIt is not possible to nest a <button> with an <a> element as it isn't valid HTML5. According to HTML5 specification, the <a> tag must not have any interactive content descendant.
Link Submit Button Using Anchor Tags In HTML In HTML, linking submit buttons using the Anchor Tag is a simple and dependable approach. Write/Declare a Submit button between the Anchor tag's Starting and Closing tags. Give a Path where you wish to link your Submit Button by using the href property of the Anchor element.
You can simply do that with javascript
window.open(url1);
window.open(url2);
And if you want to open one of that links in curren window you can replace window.open by this
window.location = url1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With