Skip to content

Change functionality of button, reformat the code to make it beautiful #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions dom_manipulation/button.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<!DOCTYPE html>
<html>
<head><title>JavaScript Button Example</title></head>

<body>
<head>
<title>JavaScript Button Example</title>
</head>

<body>
<button id='squeeze'>Squeeze me</button>

<script>
let button = document.getElementById("squeeze");
function shout(){
alert("... and I squeak");
}
button.addEventListener("click", shout);
let button = document.getElementById("squeeze");
function randomise_background_colour() {
document.body.style.backgroundColor = "#" + Math.floor(Math.random() * 16777215).toString(16);
}
button.addEventListener("click", randomise_background_colour);
</script>
</body>
</html>
</body>

</html>