I cannot seem to use the method name "all()" when using it inside an onclick(), onmouseover() or similar dom events. No errors, just nothing.
However, using the addEventListener construct works perfectly fine.
A very simple problematic page is as follows.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<!--THIS DOES NOT WORK-->
<button id="myBtn" onclick="all()">Click Me</button>
<script>
//HOWEVER THIS WORKS (uncomment first)
//document.querySelector('#myBtn').addEventListener('click', all);
function all() {
console.log('all clicked');
}
</script>
</body>
</html>
I've tried putting the all() method before the call, to no avail. Has left me scratching my head. Has anyone ever run into this before?