gpt4 book ai didi

jquery - 如何知道一个对象是否是 jQuery 对象

转载 作者:行者123 更新时间:2023-11-30 23:50:03 25 4
gpt4 key购买 nike

我创建了一个函数,它告诉变量是否保存 jQuery 对象,或者是否有任何替代品。下面是我的代码

/*Is there any substitute of this function*/

function iSJqueryObj(elm)
{
return elm && jQuery.isFunction(elm.html);
}

http://jsfiddle.net/kE7Lp/3/

最佳答案

使用instanceof :

console.log(elm instanceof jQuery);

或者:

console.log(elm instanceof $);

演示:http://jsfiddle.net/karim79/8jUKX/

关于jquery - 如何知道一个对象是否是 jQuery 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8520546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com