hi,
I''m using the prototype element function
$(''id'').toggle(); to toggle
visibility but my problem is that I have multiple divs with the same
id name.
For example:
<div id="friendThumbs"
onmouseover="$(''friendInfo'').toggle();"
onmouseout="$(''friendInfo'').toggle();">
<img src="/images/rodrigo.jpg" />
<div id="friendInfo" style="display:none;">
<ul>
<li>Location: Los Angeles, CA</li>
</ul>
</div>
</div>
<div id="friendThumbs"
onmouseover="$(''friendInfo'').toggle();"
onmouseout="$(''friendInfo'').toggle();">
<img src="/images/celo.jpg" />
<div id="friendInfo" style="display:none;">
<ul>
<li>Location: Brazil</li>
</ul>
</div>
</div>
when I rollover the first div (friendThumbs) it show its friendInfo
div. However; when I rollover the next div (friendThumb) it shows the
first div friendInfo instead of its friendInfo div.
How can I fix that?
Thanks in advance
Rodrigo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
On Nov 27, 12:28 pm, Rodi <rodr...-pRLWnb2mcV5Wk0Htik3J/w@public.gmane.org> wrote:> hi, > > I''m using the prototype element function $(''id'').toggle(); to toggle > visibility but my problem is that I have multiple divs with the same > id name.That is invalid HTML, ID''s must be unique in the document. [...]> when I rollover the first div (friendThumbs) it show its friendInfo > div. However; when I rollover the next div (friendThumb) it shows the > first div friendInfo instead of its friendInfo div. > > How can I fix that?Give them unique IDs. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 26, 2007, at 9:30 PM, RobG wrote:> > > > On Nov 27, 12:28 pm, Rodi <rodr...-pRLWnb2mcV5Wk0Htik3J/w@public.gmane.org> wrote: >> hi, >> >> I''m using the prototype element function $(''id'').toggle(); to toggle >> visibility but my problem is that I have multiple divs with the same >> id name. > > That is invalid HTML, ID''s must be unique in the document. > > [...] >> when I rollover the first div (friendThumbs) it show its friendInfo >> div. However; when I rollover the next div (friendThumb) it shows the >> first div friendInfo instead of its friendInfo div. >> >> How can I fix that? > > Give them unique IDs. > > > -- > RobI just did this, using classes, this morning: $$(''div.someClass'').each(function(elm){ new Insertion.Before(elm,''<span class="toggle">Hide</span>''); $$(''span.toggle'').invoke(''observe'',''click'',function(evt){ elm.toggle(); var myself = Event.element(evt); var text = (myself.innerHTML.indexOf(''Show'') > -1) ? ''Hide'' : ''Show''; myself.update(text); }); }); There''s probably loads of room for improvement in there, but this did the trick in a non-id-specific way. Yes, I know this is deprecated syntax on the Insertion, I have not updated my large live site yet. Walter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---