I want to execute a function with argument from addEventListener on button click. i wrote some code,but here function is executing before button click.....below sample code....
- <form>
- <button id="btn">Click Here</button>
- </form>
- <script>
-
- function abc(num) {
- alert(num);
- };
- document.getElementById('btn').addEventListener('click', abc(2));
- </script>
help me how to solve this problem...