[thelist] Separate text node from containing element using JS?

Barney Carroll barney at textmatters.com
Mon Mar 12 13:03:30 CDT 2007

Matt Warden wrote:
> I would suggest using JS to insert the spans. Some might say this is
> inappropriate use of JS, but I think it's better than trying to do the
> styling in JS (here you would just be modifying the structure, and CSS
> would be defining the style).
> pseudo:
> lists = getelementsbyclassname('whatever') // available in many
> utility libraries, e.g. YUI
> for each list in lists {
>     listitems = list.getElementsByTagName('li');
>     for each li in listitems {
>         copy text
>         delete text node
>         create span
>         create text node with copied text
>         append span to li
>     }
> }

This is what I was after... However I've decided that javascript is 'too 
late' (I'm almost certain some of my actual clients disable javascript) 
- if I'm going to do this at all I should find a way for my content 
editor (Kupu) to insert the spans there in the markup. It shouldn't be a 
case of client-side activity, methinks.

Thanks anyway,

More information about the thelist mailing list