TommyMaintz
24 Jan 2007, 2:42 AM
Hey guys,
I don't know if this is something wrong on my side or just in my brain but i have the following markup:
<div id="websites">
<div id="website-1">
...</p>
<div>...</div>
</div>
<div id="website-2">
...</p>
<div>...</div>
</div>
<div id="website-3">
...</p>
<div>...</div>
</div>
<div id="website-4">
...</p>
<div>...</div>
</div>
<div id="website-5">
...</p>
<div>...</div>
</div>
<div id="website-6">
...</p>
<div>...</div>
</div>
<div id="website-7">
...</p>
<div>...</div>
</div>
<div id="website-8">
...</p>
<div>...</div>
</div>
<div id="website-9">
...</p>
<div>...</div>
</div>
...etc
Now i want to select website 2, 5, 8.
With cssQuery i was using the following query:
'#websites > div:nth-child(3n+2)'
This one doesn't work in DomQuery.
I looked up the definition of nth-child on w3. Here it is:
The :nth-child(an+b) pseudo-class notation represents an element that has an+b-1 siblings before him...
This means that the proper selector to do this would be:
'#websites > div:nth-child(3n+2)'
With DomQuery however its all a bit strange.
When I use:
'#websites > div:nth-child(odd)'
it returns website-1, website-3, website-5....
this is correct
When i use:
'#websites > div:nth-child(even)'
it returns website-2, website-4, website-6... etc
this is correct aswell
When i use:
'#websites > div:nth-child(2)'
it returns p, p, p, p, p.... etc
while it should return website-2 (i think, this is what i dont know for sure...)
When i use:
'#websites > div:nth-child(3n+2)'
it returns nothing.
Can somebody maybe explain to me what i am doing wrong?
Or is it just strange behaviour of DomQuery.
I don't know if this is something wrong on my side or just in my brain but i have the following markup:
<div id="websites">
<div id="website-1">
...</p>
<div>...</div>
</div>
<div id="website-2">
...</p>
<div>...</div>
</div>
<div id="website-3">
...</p>
<div>...</div>
</div>
<div id="website-4">
...</p>
<div>...</div>
</div>
<div id="website-5">
...</p>
<div>...</div>
</div>
<div id="website-6">
...</p>
<div>...</div>
</div>
<div id="website-7">
...</p>
<div>...</div>
</div>
<div id="website-8">
...</p>
<div>...</div>
</div>
<div id="website-9">
...</p>
<div>...</div>
</div>
...etc
Now i want to select website 2, 5, 8.
With cssQuery i was using the following query:
'#websites > div:nth-child(3n+2)'
This one doesn't work in DomQuery.
I looked up the definition of nth-child on w3. Here it is:
The :nth-child(an+b) pseudo-class notation represents an element that has an+b-1 siblings before him...
This means that the proper selector to do this would be:
'#websites > div:nth-child(3n+2)'
With DomQuery however its all a bit strange.
When I use:
'#websites > div:nth-child(odd)'
it returns website-1, website-3, website-5....
this is correct
When i use:
'#websites > div:nth-child(even)'
it returns website-2, website-4, website-6... etc
this is correct aswell
When i use:
'#websites > div:nth-child(2)'
it returns p, p, p, p, p.... etc
while it should return website-2 (i think, this is what i dont know for sure...)
When i use:
'#websites > div:nth-child(3n+2)'
it returns nothing.
Can somebody maybe explain to me what i am doing wrong?
Or is it just strange behaviour of DomQuery.