Sam Selikoff
Sam Selikoff

Reputation: 12704

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:

enter image description here

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

Upvotes: 5

Views: 1309

Answers (1)

adambullmer
adambullmer

Reputation: 1012

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

Upvotes: 6

Related Questions