Assuming I have this:
var wrap = $("#someId");
I need to access the original object that I would get by
var orig = document.getElementById("someId");
But I don't want to do a document.getElementById
.
Is there something I can use on wrap
to get it? something like:
var orig = wrap.original();
I searched high and low but I didn't find anything; or maybe I'm not looking for the right thing.
Best Answer
The function for this is
get
. You can pass an index toget
to access the element at that index, sowrap.get(0)
gets the first element (note that the index is 0-based, like an array). You can also use a negative index, sowrap.get(-2)
gets the last-but-one element in the selection.You can also use array-like syntax to access elements, e.g.
wrap[0]
. However, you can only use positive indexes for this.