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);
}

DOM How-To


Web Scripting Overview


HTML Input


Web Scripting Examples


Web Scripting Misc


jQuery


node.js

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials