onclick
by hannahtaylor
HTML
<button onclick="doSomething()">
Click Me
</button>
<p id="text"></p>
JavaScript
function doSomething() {
document.getElementById('text').innerHTML = "Congrats, You clicked the button! When you " +
"clicked the button, it called the doSomething() function which printed this text. ";
}