I have something like:
<div id="outer">
<span>the text</span>
<a href="javascript:void(0);">the link</a>
</div>
I then observe the link as...
$(''outer'').observe(''click'', doSomething);
and deal with it as...
function doSomething(e) {
e.stop();
elt = e.element();
if(elt.tagName == ''A'') {
alert(elt.up().firstChild.innerHTML);
}
}
That brings me to my question. The user clicked on the ''A''
link, so I
want to alert the text that''s in the adjoining span. I walked up to
the div, then down to the first child node (I guess previous() would
have worked...). Anyhow, the only way I know to get the information
in the span is using innerHTML, but something tells me there is a
portability bug waiting to bite me.
Any help is appreciated.
Thx
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
innerHTML:
mText = document.getElementById("mContainer").innerHTML;
DOM:
mText = document.getElementById("mContainer").firstChild.nodeValue;
--~--~---------~--~----~------------~-------~--~----~
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 2:30 AM, Roland wrote:> innerHTML: > mText = document.getElementById("mContainer").innerHTML; > > DOM: > mText = document.getElementById("mContainer").firstChild.nodeValue;Works like a charm: mText = extendedElement.firstChild.nodeValue Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---