Possible Duplicate:
jQuery test for whether an object has a method?
I want to set if Function Exists before Calling javascript can you help me how do this and apply on this script
$(document).ready(function() {
$(".cs-text-cut").lettering('words');
});
I'm assuming that you're wanting to check and make sure that lettering
exists, try this:
http://api.jquery.com/jQuery.isFunction/
As of jQuery 3.3, jQuery.isFunction() has been deprecated. In most cases, its use can be replaced by typeof x === "function".
Here's an example:
if ( $.isFunction($.fn.lettering) ) {
$(".cs-text-cut").lettering('words');
}
For jQuery 3.3 and higher use:
if (typeof $.fn.lettering === "function" ) {
$(".cs-text-cut").lettering('words');
}