如何检查功能是否在jquery上,但函数是否在另一个.js文件中?如何检查函数是否存在?
validation.js:
if ($.isFunction('payment')) {
$('[data-numeric]').payment('restrictNumeric');
$('.cc-number').payment('formatCardNumber');
$('.cc-exp').payment('formatCardExpiry');
$('.cc-cvc').payment('formatCardCVC');
}
这是假的,因为FUNC款项是在payments.js。
可能重复[Javascript检查是否存在函数](http://stackoverflow.com/questions/1042138/javascript-check-if-function-exists) – Liam
你想检查jQuery'$'是否定义了函数。防爆。 '$ .myFunc' – Tushar
可能的重复http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type – ambodi