HTML: Button

By Xah Lee. Date: . Last updated: .

Button Example

Code

<button id="button47516" type="button">Click Me</button>

<span id="show19465"></span>

Here is JavaScript to detect and act on click.

{
  const button47516 = document.getElementById("button47516");
  const show19465 = document.getElementById("show19465");

  const f_update = () => {
    show19465.textContent = show19465.textContent + "clicked ";
  };

  button47516.addEventListener("click", f_update, false);
}

HTML Input tutorial