# Visual\_effect and change focus

**URL:** <https://www.ruby-forum.com/t/visual-effect-and-change-focus/145979>\
**Category:** Rails\
**Created:** [August 15, 2008, 7:26pm UTC](https://www.ruby-forum.com/t/visual-effect-and-change-focus/145979 "2008-08-15T19:26:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LAB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@LAB](https://www.ruby-forum.com/u/LAB)\
**Post date:** [August 15, 2008, 7:26pm UTC](https://www.ruby-forum.com/t/visual-effect-and-change-focus/145979/1 "2008-08-15T19:26:13Z")

</div>

Hello -

I am using a visual\_effect like this:

\<%= link\_to "Question #1", "#", :onclick =\> visual\_effect(:toggle\_blind, 'question1') %\>

Question #1: Answer

So that when the link to Question #1 is clicked on, it drops down the  
answer in the hidden

 right below the question. How can I change  
the focus, so that the browser window focus doesn’t jump to the top of  
the screen, but instead focuses on my hidden div?

Thanks for any help!!

LAB

---

<div class="post-metadata">

**Author:** ![LAB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@LAB](https://www.ruby-forum.com/u/LAB)\
**Post date:** [August 15, 2008, 10:37pm UTC](https://www.ruby-forum.com/t/visual-effect-and-change-focus/145979/2 "2008-08-15T22:37:24Z")

</div>

LAB wrote:

> Hello -
> 
> I am using a visual\_effect like this:
> 
> \<%= link\_to "Question #1", "#", :onclick =\> visual\_effect(:toggle\_blind, 'question1') %\>
> 
> Question #1: Answer
> 
> So that when the link to Question #1 is clicked on, it drops down the  
> answer in the hidden
> 
> right below the question. How can I change  
> the focus, so that the browser window focus doesn’t jump to the top of  
> the screen, but instead focuses on my hidden div?
> 
> Thanks for any help!!
> 
> LAB
> 
> Well, I guess you could make an href that points to “#question1”…
> 
> Lake

---

<div class="post-metadata">

**Author:** ![LAB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ba8739/32.png) [@LAB](https://www.ruby-forum.com/u/LAB)\
**Post date:** [August 16, 2008, 9:26pm UTC](https://www.ruby-forum.com/t/visual-effect-and-change-focus/145979/3 "2008-08-16T21:26:33Z")

</div>

Ah, ha! That’s what I was missing … this fixes it …

\<%= link\_to "Question #1", "#question1", :onclick =\> visual\_effect(:toggle\_blind, 'question1') %\>

note the addition of “question1” after the #, passed as the 2nd  
parameter.

Thanks!!  
LAB

On Aug 15, 4:37 pm, Lake D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
