If clicked javascript code example
Example 1: how to detect a button click in javascript
if(document.getElementById('button').clicked == true)
{
alert("button was clicked");
}
Example 2: javascript onclick
document.getElementById("myBtn").addEventListener("click", function() {
alert("Hello World!");
});
Example 3: how to check if you click something in javascript
const element = document.getElementById('profile_title')
element.addEventListener("click", () => {
alert('hello');
});
Example 4: how to check if the button is clicked or not in javascript
if(document.getElementbyId("id do item").clicked == true){
window.alert("ok")
}
Example 5: javascript onclick
var myElem = document.getElementByID('ElemID');
myElem.onclick = function() {
}
Example 6: button click function in js
<script>
$(document).ready(function(){
$('#MyButton').click(function(){
CapacityChart();
});
});
</script>
<input type="button" value="Capacity Chart" id="MyButton" >