HTML: Button

By Xah Lee. Date: . Last updated: .

Here's how to create a HTML button.

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

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

Here's 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);
}
βˆ‘ JS in Depth
XAH Β BUY NOW

JS in Depth

JS Obj Ref

DOM


DOM

Overview

Basic Examples

HTML Input

Web Scripting Examples

Web Scripting Misc

jQuery

node.js