# Check if an HTML element exists in rjs

**URL:** <https://www.ruby-forum.com/t/check-if-an-html-element-exists-in-rjs/170235>\
**Category:** Rails\
**Created:** [June 14, 2009, 6:34pm UTC](https://www.ruby-forum.com/t/check-if-an-html-element-exists-in-rjs/170235 "2009-06-14T18:34:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartolome](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bcef8e/32.png) [@bartolome](https://www.ruby-forum.com/u/bartolome)\
**Post date:** [June 14, 2009, 6:34pm UTC](https://www.ruby-forum.com/t/check-if-an-html-element-exists-in-rjs/170235/1 "2009-06-14T18:34:11Z")

</div>

Does anybody knows how can I check if an HTML element exists via rjs?  
I’ve  
been trying, for example:

if page[‘edit\_company\_’ + @id]

if page[‘edit\_company\_’ + @id].blank?

But it generates a js code with a .blank? and it doesn’t make any sense  
in  
js. I need this to take some actions only if a certain element exists.  
Any  
suggestion? Thanks in advance.

–  
Rodrigo F.  
Web D.  
SCJP

---

<div class="post-metadata">

**Author:** ![bartolome](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bcef8e/32.png) [@bartolome](https://www.ruby-forum.com/u/bartolome)\
**Post date:** [June 15, 2009, 12:35am UTC](https://www.ruby-forum.com/t/check-if-an-html-element-exists-in-rjs/170235/2 "2009-06-15T00:35:25Z")

</div>

On Jun 14, 5:33 pm, Rodrigo F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 

I wrote a bit about this a little while back:

> **[Conditional RJS explained - Space Vatican](https://www.spacevatican.org/2008/5/26/conditional-rjs-explained/)**
>
> RJS is one of those nifty little things that catches your eye when you first start off using Rails. You very quickly get to add ajax and whizzy …

Fred
