# Can I use link\_to\_function with html\_options somehow?

**URL:** <https://www.ruby-forum.com/t/can-i-use-link-to-function-with-html-options-somehow/85112>\
**Category:** Rails\
**Created:** [February 10, 2007, 2:38am UTC](https://www.ruby-forum.com/t/can-i-use-link-to-function-with-html-options-somehow/85112 "2007-02-10T02:38:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [February 10, 2007, 2:38am UTC](https://www.ruby-forum.com/t/can-i-use-link-to-function-with-html-options-somehow/85112/1 "2007-02-10T02:38:14Z")

</div>

I’m using link\_to\_function with visual\_effect to toggle a list down and  
up.

I would like to add { :class =\> ‘mystyle’ } to the link\_to\_function  
statement but don’t see it accepts html\_options based on the API.

Is there a work around of some kind to apply a css class style to a link  
created by link\_to\_function?

Thanks,  
DAN

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [February 10, 2007, 4:38am UTC](https://www.ruby-forum.com/t/can-i-use-link-to-function-with-html-options-somehow/85112/2 "2007-02-10T04:38:33Z")

</div>

> I’m using link\_to\_function with visual\_effect to toggle a list down and  
> up.
> 
> I would like to add { :class =\> ‘mystyle’ } to the link\_to\_function  
> statement but don’t see it accepts html\_options based on the API.
> 
> Is there a work around of some kind to apply a css class style to a link  
> created by link\_to\_function?

I think it will…

[http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000630](http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000630)

link\_to\_function(“Show me more”, nil, :id =\> “more\_link”) do |page|  
…  
end  
Produces:  
\<a href=“#” id=“more\_link” onclick="try {  
…

The :id made it through in the right spot, so putting :class right there  
should also work I would think.

-philip

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [February 10, 2007, 6:14am UTC](https://www.ruby-forum.com/t/can-i-use-link-to-function-with-html-options-somehow/85112/3 "2007-02-10T06:14:06Z")

</div>

Thanks - I adjusted my parens and got it working.  
DAN
