Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to give a href inside the button tag in html

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??

like image 966
Raju.allen Avatar asked Jan 13 '12 07:01

Raju.allen


People also ask

How do you add a link to a 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.

Can I put an A tag inside a button?

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.

How do I link a HTML file to a button?

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.


1 Answers

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;
like image 88
Chuck Norris Avatar answered Oct 05 '22 04:10

Chuck Norris