Prevent Function to Execute more than once (automatically) using jQuery

Some of you might face a situation where our function is executed more than once and that too automatically. As said, let say we have clicked a button one time, but it's calling function is called more than once. This type of problem majorly occurs in Accordians.
 
For such kind of situation you just need to modify your code a little bit and everything will run in a proper manner.
 
Just add "event" in the function() and check for (event.handled != true). For the first time this condition will be true because we have not defined event.handled anywhere, so it's undefined at first time.
 
At the end of your function add  (event.handled = true), this will apply a value and next time the condition will become false. So your code will not be a hit on single click.
 
Example: 
  1. $(document).on('click''.btnSubmit'function (event) {  
  2. if (event.handled != true) {  
  3.    
  4.    
  5. ------------>>>>>>>>>>>   
  6.    
  7.    
  8. Your Code   
  9.    
  10. ---------------<<<<<<<<<<<<<<<   
  11. event.handled = true;  
  12. }  
  13. });