# Link\_to\_function to remove a \<div\> in both IE and FF

**URL:** <https://www.ruby-forum.com/t/link-to-function-to-remove-a-div-in-both-ie-and-ff/143458>\
**Category:** Rails\
**Created:** [July 18, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/link-to-function-to-remove-a-div-in-both-ie-and-ff/143458 "2008-07-18T20:48:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [July 18, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/link-to-function-to-remove-a-div-in-both-ie-and-ff/143458/1 "2008-07-18T20:48:08Z")

</div>

Hey All,

I’ve got a partial \_research\_areas.html.erb, which has a  
link\_to\_function call for removing the div defined by the partial, like  
so:

# =========================

 \<% fields\_for\_research\_area(research\_areas) do |ra\_form| %\> 

\<%= ra\_form.collection\_select(:research\_area\_id , ResearchArea.get\_list , :id, :name , {:prompt =\> true}) %\> \<% link\_to\_function 'Remove', "this.up().remove();" %\>

 \<% end %\> 
# =========================

That works just fine in FF, but in IE nothing seems to happen (apart  
from the page scrolling up to the top). The ticklish thing here is that  
there can be any number of these divs on the page, all of which have the  
same id. (These get added on the client w/another ltf call that renders  
the partial into the page.) The above removes the correct div in FF,  
but other things I’ve tried that do effect a remove in IE just remove  
the first one.

I’ve played around w/trying to give each div a unique id, but haven’t  
come up w/a good solution for accomplishing that, and the above works so  
well in FF, I was hoping there might be some magic javascript out there  
that would do the trick in both browsers. Is there?

Thanks!

-Roy

Roy P.  
Research Analyst/Programmer  
Group Health Center For Health Studies (Cancer Research Network)  
(206) 287-2078  
Google Talk: rpardee

---

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [July 18, 2008, 9:02pm UTC](https://www.ruby-forum.com/t/link-to-function-to-remove-a-div-in-both-ie-and-ff/143458/2 "2008-07-18T21:02:14Z")

</div>

Hrm–nevermind. More playing led me to this:

$(this).up().remove()

Which works in both IE and FF.

TODO: Learn javascript… 😛

Thanks!

-Roy
