Applying a function to all buttons? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Applying a function to all buttons? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Im working on a quick script to apply an alert and redirect message to all anchors and buttons on a page. So far, I have this working for all anchors:

.addEventListener('click', function (event) {
        ( === 'A' || === 'button') { 
        alert("test");'', '_self');

When i try to apply the same idea to all buttons (see after the || in the script), it does not apply. Am I missing something?

Answer results are capitalized.


We are here to answer your question about Applying a function to all buttons? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji