tags:

views:

68

answers:

1

Hi,

It's no problem to find an element by position and the position of an element in Javascript. But is there are general way to compare them?

The only way I could think of is comparing ids or classnames, but not all elements have ids or classnames.

A: 

If you want to compare two element pointers for being the same element, just use the comparison operator. This can be easily proven because

document.body == document.body

For example, if I somehow had a references to two elements I didn't know:

if (element1 == element2) ...
Delan Azabani