Maybe there's a better way to approach my problem.
I have a nested unordered list that contains an image (icon) and some text
in each LI. I want to extract just the text part of the LI without the
image.

<ul>
    <li id="foo"><img src="icon.png" alt="" />Foo</li>
    <li id="bar"><img src="icon.png" alt="" />Bar
        <ul>
            <li id="baz"><img src="icon.png" alt="" />Baz</li>
        </ul>
    </li>
</ul>

What I want is extract 'Foo', 'Bar', and 'Baz' from each of the LIs. Any
ideas on how to go about this, or should I restructure my html?

-Hector


On Wed, Oct 8, 2008 at 3:48 AM, Søren Erland Vestø <[EMAIL PROTECTED]>wrote:

> This might not work in IE, as IE doesn't return textnodes in childNodes.
> /Søren
>
> On 07/10/2008, at 21.24, Hector Virgen wrote:
>
> Thanks! That should do the trick :)
>
> On Tue, Oct 7, 2008 at 12:12 PM, Justin Perkins <[EMAIL PROTECTED]>wrote:
>
>>
>> I think you will need to use the native methods to get the text nodes
>> as Prototype filters them out. This will work though:
>>
>> $A( $('some-element-id').childNodes ).select( function(element){
>> return element.nodeType == 3; } )
>>
>> Or better yet:
>>
>> Element.addMethods({
>>  textNodes: function(element){
>>    return $A(element.childNodes).select( function(child){ return
>> child.nodeType == 3; } );
>>  }
>> });
>>
>> Then you can just do: $('some-element-id').textNodes();
>>
>> -justin
>>
>>
>>
>
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to