Skip to content
← Back to Community
How do I make links in buttons?
Profile icon
mmichalski115

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 [earned 5 cycles]
View Answer
Voters
Profile icon
BrodyShuffler
Profile icon
AroonnanBaskara
Profile icon
XavierPrieto
Profile icon
XuanmeiLiu
Profile icon
KeithArruda
Profile icon
gamesaver
Profile icon
mmichalski115
Comments
hotnewtop
Profile icon
Geocube101

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 }
<button><a href="target.url">button text</a></button>
Profile icon
mmichalski115

@Geocube101 nice one, thanks

Profile icon
Geocube101

You're Welcome @mmichalski115

Profile icon
KAQ357

@Geocube101 this helped me too!

Profile icon
temperatures

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

Profile icon
HamishFin

grass senior

Profile icon
Oded123

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