how to click a button using js code example
Example 1: javascript button onclick programmatically
document.getElementById("myCheck").click();
Example 2: javascript click button by id
var button = document.getElementById("button");
button.click();
Example 3: 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 4: button click function in js
<script>
$(document).ready(function(){
$('#MyButton').click(function(){
CapacityChart();
});
});
</script>
<input type="button" value="Capacity Chart" id="MyButton" >