I want to know how to get selector from $(document) & $(window)?
el = $(document);
alert(el.selector); // return nothing, I want to output -> document
el = $(window);
alert(el.selector); // return nothing, I want to output -> window
Thank you very much!
There’s no selector value when you instantiate a jQuery object from a DOM element or something like
window.If you just want to know if a jQuery object wraps
documentorwindow, do this:In fact you can also do this:
or
The
.is()function also works if you want to test for specific DOM elements too.