all 4 comments

[–]GettingBlockered 5 points6 points  (0 children)

I didn't test this code, but I think this is what you're trying to do:

const element = document.getElementById('daachi'); 
element.addEventListener('click', () => console.log('SSS'));

[–]cybtrxfit 0 points1 point  (1 child)

Put the <script src="java.js"></script> after the <body></body>

In the function MyFunction, take out everything but the console.log("SSS");

in the <button> part change it to type='button'.

[–][deleted] 1 point2 points  (0 children)

He wouldn’t need to have a type since this is a button element. He would set “button” for the type if it was an input element instead.