Ask coding questions

← Back to all posts
Why isn't my button working?
Pizzaz4me (63)

Why isn't my button working. I first tried to make it go to another file in another folder, but that didn't work. I then tried to just have a basic link to, and that didn't work either. What am I doing wrong and how do I fix it?

Answered by Coder100 (16823) [earned 5 cycles]
View Answer
Coder100 (16823)
  1. You linked your script wrong (script.js)
  2. Your functions should be lowercase brokenStuff()

Corrected code form index.html

<!DOCTYPE html>
	<title>My Website</title>
	<link rel="stylesheet" type="text/css" href="style.css">
		<h1>My Website</h1>

  	<button id="btn-yeet" onclick="BrokenStuff()">Broken Rock Paper Scissors</button>

	<script src="script.js"></script>
TestOP (12)

The button tag is in the header tag, it wouldn’t show up because of that

Pizzaz4me (63)

it's still doesn'twork @TestOP

TestOP (12)

@Pizzaz4me It does you have to open it up in a new tab. But also you can see that you are trying to load main.js not script.js which is the name of your script