<button onClick="">

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Attribute of
Creating A Button With The HTML Button Element: Here's How
What does <button onClick=""> do?
Runs a script when a button is clicked.

The onClick attribute is an event handler that instructs the browser to run a script when the visitor clicks a button.

Example usage

<button onClick="script">
Claire is seasoned technical writer, editor, and HTML enthusiast. She writes for HTML.com and runs a content agency, Red Robot Media.

Browser Support for onClick