clicked button javascript code example
Example 1: how to check if the button is clicked or not in javascript
if(document.getElementbyId("id do item").clicked == true){
window.alert("ok")
}
Example 2: javascript click button by id
var button = document.getElementById("button");
button.click();
Example 3: click button javascript
let button = document.querySelector("#IDofItem");
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" >
Example 5: element clicked js
document.addEventListener('click', function(e) {
e = e || window.event;
var target = e.target || e.srcElement,
text = target.textContent || target.innerText;
}, false);