Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if Function Exists before Calling? [duplicate]

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'); }); 
like image 421
Amjad Ali Avatar asked Dec 01 '12 06:12

Amjad Ali


1 Answers

I'm assuming that you're wanting to check and make sure that lettering exists, try this:

http://api.jquery.com/jQuery.isFunction/

Here's an example:

if ( $.isFunction($.fn.lettering) ) {     $(".cs-text-cut").lettering('words'); } 
like image 100
gregwhitworth Avatar answered Sep 23 '22 05:09

gregwhitworth