Ask coding questions

← Back to all posts
How do I make links in buttons?
mmichalski115 (3)

So I'm making a calculator that calculates area of shape and I want to make buttons that switch shapes when clicked, I got the click part done, I just need to know how to turn the buttons into links

Answered by Geocube101 (628) [earned 5 cycles]
View Answer
Comments
hotnewtop
Geocube101 (628)

Do you have the repl?

Listening if a button was clicked:

var button = document.getElementById('id_of_button');
button.addEventListener('click', function(event)
{
  //Code to execute
});

Listening if a button was clicked (using html onclick):

HTML Code

<button onclick="buttonClicked()">button text</button>

JS Code

function buttonClicked()
{
  //Code to Execute
}

Putting a link element in a button:

<button><a href="target.url">button text</a></button>
temperatures (1)

@Geocube101 WOW thanks you i was serching for like 1 days

Oded123 (1)

@HamishFin is this work for python?
if yes how do you do the button?
and where do you put the URL/link