javascript in rjs?

Hi, I'm trying to see if an element exists in my rjs:

exists = document.getElementById("checkX")

Something to that extent... how do I add that into the rjs?

Thanks

page << "exists = document.getElementById("checkX")"

Or u can do like

page << "if($('checkX')){"
Do what u need here
page << "}"