Debounce function in jQuery

I ran into the same issue. The problem is happening because the debounce function returns a new function which isn’t being called anywhere.

To fix this, you will have to pass in the debouncing function as a parameter to the jquery click event. Here is the code that you should have.

$(".my-btn").click($.debounce(250, function(e) {
    console.log("It works!");
}));

Leave a Comment