How to add event listener in JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
    <body>
        <button id="b_id">Click Here</button>

        <script>
            document.getElementById("b_id").addEventListener("click", f);

            function f() {
                document.write('function f()');
            }
        </script>

    </body>
</html> 



<!--

run:

function f()

-->

 



answered Feb 26, 2020 by avibootz

Related questions

...