Deriving an HTMLElement Object from jQuery Object

Posted by Jasconius on Stack Overflow See other posts from Stack Overflow or by Jasconius
Published on 2010-03-30T17:15:25Z Indexed on 2010/03/30 17:23 UTC
Read the original article Hit count: 456

Filed under:
|
|
|
|

I'm doing a fairly exhaustive series of DOM manipulations where a few elements (specifically form elements) have some events.

I am dynamically creating (actually cloning from a source element) several boxes and assigning a change() event to them.

The change event executes, and within the context of the event, "this" is the HTML Element Object.

What I need to do at this point however is determine a contact for this HTML Element Object. I have these objects stored already as jQuery entities in assorted arrays, but obviously

[HTMLElement Object] != [Object Object]

And the trick is that I cannot cast $(this) and make a valid comparison since that would create a new object and the pointer would be different.

So... I've been banging my head against this for a while. In the past I've been able to circumvent this problem by doing an innerHTML comparison, but in this case the objects I am comparing are 100% identical, just there's lots of them. Therefore I need a solid comparison.

This would be easy if I could somehow derive the HTMLElement object from my originating jQuery object.

Thoughts, other ideas? Help. :(

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript