how to use html onclick button work dom manipulation javascript code example
Example 1: javascript button onclick
document.getElementById('button').onclick = function() {
alert("button was clicked");
};
Example 2: html js button onclick
// In HTML:
// <button id="buttonID" onclick="yourJSFunction()">Text</button>
// In JavaScript:
function yourJSFunction() {
// Do stuff
}