element is clicked w3schools code example
Example: javascript onclick button
var button = document.querySelector('button');
button.onclick = function() {
//do stuff
}
var button = document.querySelector('button');
button.onclick = function() {
//do stuff
}