I am creating a dynamic quiz and I need to prevent a few clicks on my "next" button. In the click function, I tried to fulfill the if condition to prevent several clicks. I donβt know why this is not working. I would really appreciate your help.
var nextButton= $('<button/>', { text: 'Next', id: 'nextButton', click: function (event) { event.preventDefault(); if($("#container").filter(':animated').length>0) { return false; } } });
Here is the code, it seems to me, my JSFiddle of my application
Bonus Question: I was told that event.preventDefault() is a good practice. It's true? If so, why?
Update: Line JSFiddle # , where the code above is line 81 , if you want to communicate with the code without digging it all.
source share