tags:

views:

29

answers:

3

I need to select all span tag elements within a div with an id list_{[0-9]}+ having the following form:

<div id="list_1234" ...>
    <!-- can be nested multiple levels deep -->
        ...
            <span class="list_span">Hello</span>
</div>

How can I do that, e.g. without using jQuery? Is that possible?

+1  A: 

Why you do'nt use a common class ? You can add many class

class="list_1234 mydiv"

And your selector :

.mydiv span
remi bourgarel
No reason to put the id as a class. Should be: `<div id="list_1234" class="mydiv">`. Assuming he can change the html.
tloflin
why do you think it's an id ?
remi bourgarel
+2  A: 

You can do this with pure CSS pretty easily, just give those divs a class like this:

<div id="list_1234" class="container" ...>

And CSS like this:

.container span { /* styles */ }
Nick Craver
A: 

The only thing you can do is:

list_1 span, list_2 span, list_3 span... { ... }

Is it possible to add a "class" attribute to these divs? That's the proper way to handle multiple elements with ids.

tloflin