Hide & Show div (Element.toggle)


#1

I have 2 divs:

<%= link_to_function("Show div2", "Element.toggle('div2')") %>
<%= link_to_function("Show div1", "Element.toggle('div1')") %>

I want, when I click link: “Show div2” it hide div1 and show div2,
when i click “Show div1” it hide div2 and show div1

How can i do it?


#2

On Dec 26, 5:14 pm, Gi Ga removed_email_address@domain.invalid wrote:

How can i do it?
just make your call to link_to function toggle both divs - you aren’t
limited to a single javascript statement.

Fred


#3

Frederick C. wrote:

On Dec 26, 5:14�pm, Gi Ga removed_email_address@domain.invalid wrote:

How can i do it?
just make your call to link_to function toggle both divs - you aren’t
limited to a single javascript statement.

Fred

I can’t make it work :frowning:

By default div2 is hidden:

<%= link_to_function("Show div2", "Element.toggle('div1', 'div2)") %>
<%= link_to_function("Show div1", "Element.toggle('div1', 'div2')") %>

#4

On 26 Dec 2008, at 19:32, Gi Ga wrote:

I can’t make it work :frowning:
Just make two calls to Element.toggle

Fred


#5

Sample:

Element.toggle(‘div1’); Element.toggle(‘div2’);


Shiv

On Sat, Dec 27, 2008 at 1:29 PM, Gi Ga
removed_email_address@domain.invalidwrote:

Sample?

Posted via http://www.ruby-forum.com/.

Henny Youngman - “If at first you don’t succeed… so much for
skydiving.”


#6

Sample?