我有一个使用的插件,但如果可用,hover()
它应该使用。hoverIntent()
我将如何以最小的麻烦做到这一点?
这将检测是否已包含 hoverIntent,并在这种情况下修改hover
方法hoverIntent
。
var bindMethod = $.isFunction(jQuery().hoverIntent) ? 'hoverIntent' : 'hover';
element[bindMethod](
function() {
// Mouse over
},
function() {
// Mouse out
});
然后,您可以在您的插件上留言,上面写着...
- 与hoverIntent兼容。