Comment by xiphias2
12 days ago
As you can see even the basic documentation is compromised at this point:
https://unplannedobsolescence.com/blog/behavior-belongs-in-h...
<button onclick="alert('I was clicked!')">Click me</button>
,,You can find HTML attribute equivalents for many of the event handler properties; however, you shouldn't use these — they are considered bad practice. It might seem easy to use an event handler attribute if you are doing something really quick, but they quickly become unmanageable and inefficient.''
,,You should never use the HTML event handler attributes — those are outdated, and using them is bad practice.''
And then proceeds to suggest this:
<button>Click me</button>
<script> const btn = document.querySelector("button")
btn.addEventListener("click", () => { alert('I was clicked!') }) </script>
After this, next step would be putting javascript to a separate file, and on a slow mobile connection in a random airport with thousands of people using the same wifi, a simple working code gets timeouts.
20 years ago all I needed to know was this, and it worked great:
<button onclick="alert('I was clicked!')">Click me</button>
No comments yet
Contribute on Hacker News ↗