HTML Event Attributes:
<button onclick="displayDate()">Try it</button>
Assign Events Using the HTML DOM:
<script>
document.getElementById("myBtn").onclick = function(){ displayDate() };
</script>
What is the difference between these two ? Any advantages in using (Assign Events Using the HTML DOM) ?
Thanks
The advantage is you don't mess js code with html, it permits you to separate programming layers. This renders your code cleaner and less prone to bugs. A practice that complies with web accessibility rules and good programming foundations.