How to check if an object is a jQuery event

Related: Check if object is a jQuery object

I have an object x , and after running console.log(x) Chrome's debugger shows me this:

在这里输入图像描述

How can I check if x is a jQuery.Event using JavaScript? (I've tried Object.getPrototypeOf , toString and obj.constructor ).


Agreeing @Rocket's comment: instanceof is the way to go. You can try this on SO's website in the JS console

var x = $.Event()
x instanceof $.Event

More information can be found in this eerily similar post: https://stackoverflow.com/a/1853246/1883547

链接地址: http://www.djcxy.com/p/83944.html

上一篇: 如何应用jQuery实例的类型警卫?

下一篇: 如何检查一个对象是否是一个jQuery事件