我有一个 jQuery 插件。选项之一是对动画使用什么缓动方法。我希望能够在继续使用指定的缓动方法调用 $.animate(...)
函数之前检查缓动方法是否已定义。就像这样:
var easingMethod = option.easing;
if (!IsDefined(easingMethod)) easingMethod = 'linear';
IsDefined()
函数是什么?
我可以做if (typeof(easingMethod)==undefined)
但是typeof(easingMethod)==='string'
。我更多地思考的是
function isDefined(s) {
// If a method named 's' is defined, return true, else false
}
我不知道该怎么做。
最佳答案
这个怎么样?
function isDefined(s) {
return $.easing.hasOwnProperty(s);
}
关于jquery - 如何检查是否定义了特定的 jquery-easing 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15051026/