Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to trigger a function where a dynamic button triggers a function.

What I have tried:

I tried using the "onclick" attribute of a button, but that didn't work. Then I binded it with jQuery, and then the event listener at least showed up in Chrome DevTools, but nothing happened. But when the function was run from the console it worked. Find the video here.

I am using this to bind the button:
JavaScript
$('button#prev').on('click', window.prev);
$('button#next').on('click', window.next);

as you can see in chrome devtools(in the video), the button is bound, but it still doesn't work. Please Help, and Thank You!
Posted
Updated 8-Aug-19 7:31am
v2
Comments
Afzaal Ahmad Zeeshan 8-Aug-19 0:19am    
Please share your code, we cannot guess what is going wrong there.

Since you say that the code is for a dynamic button, how are you creating the button and attaching it to the DOM?
Nv7 10-Aug-19 13:19pm    
Okay I have updated the question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900