# Help me .hide() the div!

**URL:** <https://www.ruby-forum.com/t/help-me-hide-the-div/88898>\
**Category:** Rails\
**Created:** [March 15, 2007, 1:35pm UTC](https://www.ruby-forum.com/t/help-me-hide-the-div/88898 "2007-03-15T13:35:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [March 15, 2007, 1:35pm UTC](https://www.ruby-forum.com/t/help-me-hide-the-div/88898/1 "2007-03-15T13:35:03Z")

</div>

here is my code:

ï¼œinput id=‘the\_input’ type=‘text’ /\>

\<%= observe\_field(:the\_input,  
:frequency =\> 0.5,  
:update =\> ‘the\_result’,  
#…  
)%\>  
\<%= link\_to\_function(‘the link’, “$(‘the\_input’).value=‘new  
value’;$(‘the\_result’).hide( );”)

When a user click the link, the\_input’s value will be updated, which  
fires  
the observer, then the\_result div will be showed, and it’s bad,  
because I intend to hide the div, if the\_input’s value  
is changed not by typing in the input filed, but by clicking the link,  
and that’s why I added “$(‘the\_result’).hide( );” to link\_to\_function.  
but now this .hide() is useless…

So how can I correct it?

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [March 15, 2007, 1:46pm UTC](https://www.ruby-forum.com/t/help-me-hide-the-div/88898/2 "2007-03-15T13:46:47Z")

</div>

try using Element.hide(‘the\_result’)

Nanyang Z. wrote:

> here is my code:
> 
> ï¼œinput id=‘the\_input’ type=‘text’ /\>
> 
> \<%= observe\_field(:the\_input,  
> :frequency =\> 0.5,  
> :update =\> ‘the\_result’,  
> #…  
> )%\>  
> \<%= link\_to\_function(‘the link’, “$(‘the\_input’).value=‘new  
> value’;$(‘the\_result’).hide( );”)

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [March 15, 2007, 2:56pm UTC](https://www.ruby-forum.com/t/help-me-hide-the-div/88898/3 "2007-03-15T14:56:25Z")

</div>

Steven Albarracin wrote:

> try using Element.hide(‘the\_result’)

where to put it?

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [March 15, 2007, 3:42pm UTC](https://www.ruby-forum.com/t/help-me-hide-the-div/88898/4 "2007-03-15T15:42:42Z")

</div>

Not sure what your question is anymore but if its to create a link that  
shows and hides a div

\<%=link\_to\_function(“the link”, nil,:onclick =\>  
“Element.toggle(‘the\_result’)”)%\>

Nanyang Z. wrote:

> Steven Albarracin wrote:
> 
> > try using Element.hide(‘the\_result’)
> 
> where to put it?

---

<div class="post-metadata">

**Author:** ![xain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/82dd89/32.png) [@xain](https://www.ruby-forum.com/u/xain)\
**Post date:** [March 16, 2007, 5:35am UTC](https://www.ruby-forum.com/t/help-me-hide-the-div/88898/5 "2007-03-16T05:35:23Z")

</div>

Steven Albarracin wrote:

> Not sure what your question is

I know Element.hide(‘the\_result’) or $(‘the\_result’).hide( ) will hide a  
div,

but my problem is:  
the link, which intend to hide the div, trigger an observer, and this  
observer make the div show again. I don’t know how to turn off the  
observer when the link is clicked.
