TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ajit N
NA
352
72.3k
How to pass function with argument in addEventListener ?
Mar 9 2021 6:18 AM
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...
Reply
Answers (
2
)
Datepicker css issue
Javascript Datetime conversion