HTML: Button

By Xah Lee. Date: . Last updated: .

Here is how to create a HTML button.

<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);
JavaScript in Depth

DOM Scripting


DOM Methods

Basic Examples

HTML Input

Web Scripting Examples

Web Scripting Misc