button clicked in javascript code example
Example 1: click button javascript
// Create variable for what you are trying to click
let button = document.querySelector("#IDofItem");
// Click the button
if (button) {
button.click();
}
else {
console.log("Error");
}
Example 2: javascript onclick button
var button = document.querySelector('button');
button.onclick = function() {
//do stuff
}