eventListeners or inline events [duplicate]

so I’m learning javascript and I was wondering if I want to add an event should I use an inline event that looks like this <button onclick="showImage()" or should I use the addEventListener that looks like this theButton.addEventListener("click", showImage); and wich would be better for browsers compatibility

Source: JavaSript – Stack Overflow

November 28, 2021
Category : News
Tags: Events | frontend | html | javascript | onclick

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.