如何检查变量是jQuery对象还是普通DOM元素? [英] How do I check if a variable is a jQuery object or plain DOM element?
本文介绍了如何检查变量是jQuery对象还是普通DOM元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查变量是jQuery对象还是普通DOM元素?
How do I check if a variable is a jQuery object or plain DOM element?
推荐答案
- jquery对象具有
jquery
属性。 - jquery对象是
jQuery实例
(instanceof
) - DOM元素具有
nodeType
属性 - A jquery object has a
jquery
property. - A jquery object is an
instanceof jQuery
(instanceof
on MDN) - A DOM element has a
nodeType
property
这篇关于如何检查变量是jQuery对象还是普通DOM元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文