<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
class Button {
constructor() {
this.button = document.createElement("button");
this.button.innerText = "Click Me";
this.button.addEventListener("click", this.handleClick.bind(this));
document.body.appendChild(this.button);
}
handleClick() {
alert("Button clicked!");
}
}
const myButton = new Button();
document.body.appendChild(myButton.button);
</script>
</body>
</html>