cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

checking element equality in javascript (rhino)

jsulak
1-Newbie

checking element equality in javascript (rhino)

Hey everybody,

Let's say I do the following in Arbortext:

var document = Application.activeDocument;
var a = document.getElementById("stuff");
var b = document.getElementById("stuff");

So both a and b point to the same DOM element. Now, if I check their equality:

a == b

I get "false." Why is that? Shouldn't both variables contain references to the same object, and therefore be equal? Is there a simple way to check for element equality in javascript?

Note that when I do the same thing in a web browser, I get "true," like I expect.

Thanks,

James


2 REPLIES 2

Hi James--

Try a.equals(b).

(FWIW, I think the behavior you're seeing is due to the way everything
in Rhino is actually Java objects under the hood.)

--Clay
jsulak
1-Newbie
(To:jsulak)

Thanks, Clay, that works perfectly.

-James
Top Tags