Virajsinh

jQuery Check if Function Exists Example

Jul 6th, 2020
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function somenoobfunction() {
  2.     }  
  3.  
  4.     // using jQuery
  5.     if ($.isFunction(window.somenoobfunction)) {
  6.         //execute it
  7.         somenoobfunction();
  8.     } else {
  9.         //doesnt exists... cry?!?
  10.         document.writeln('somenoobfunction does not exist');
  11.     }
RAW Paste Data