Core Code
Modern Dev Handbook
☰
HTML Contents
✕
HTML Guide
HTML Home
HTML Introduction
HTML Editors
HTML Basic
HTML Elements
HTML Attributes
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Quotations
HTML Comments
HTML Colors
HTML CSS
HTML Links
HTML Images
HTML Favicon
HTML Page Title
HTML Tables
HTML Lists
HTML Block & Inline
HTML Div
HTML Classes
HTML Id
HTML Buttons
HTML Iframes
HTML JavaScript
HTML File Paths
HTML Head
HTML Layout
HTML Responsive
HTML Computercode
HTML Semantics
HTML Style Guide
HTML Entities
HTML Symbols
HTML Emojis
HTML Charsets
HTML URL Encode
HTML vs. XHTML
Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
Input Form Attributes
Graphics
HTML Canvas
HTML SVG
Media
HTML Media
HTML Video
HTML Audio
HTML Plug-ins
HTML YouTube
Web APIs
HTML Web APIs
HTML Geolocation
HTML Drag and Drop
HTML Web Storage
HTML Web Workers
HTML SSE
HTML
→
HTML JavaScript
Button Click Event
Example reacting to a button click.
Preview
Code
<button onclick="document.body.style.background='lightyellow';"> Change Background </button>
More HTML JavaScript Examples (7)
JavaScript Alert
Change Text Content
Change Style with JavaScript
Show and Hide Element
Change Image with JavaScript
Display Current Date
Toggle Text
← Change Style with JavaScript
Show and Hide Element →