Thread: Resolved Jquery nth term append
View Single Post
Old 11-14-2012, 07:04 PM   PM User | #6
CHEWX
Regular Coder

 
Join Date: Dec 2010
Posts: 124
Thanks: 17
Thanked 6 Times in 6 Posts
CHEWX is an unknown quantity at this point
Quote:
Originally Posted by devnull69 View Post
YES, you can do it for "class"

NO, it won't work for "id"
Really, so if I was to change the ID to a class and add this code

Code:
$(document).ready(function() {
$(".article-inspir:nth-child(2n)").append("<div style='clear:both;'></div>");
});
It would would ? Doesn't that rubbish what was said above ?

Quote:
Originally Posted by rnd me View Post
Code:
#article-inspir:nth-child(2n)
hits both
Code:
<article id=​"article-inspir" class=​"drop-shadow curved curved-hz-1">

i will say however, that you shouldn't actually need to use scripts for this.
simply use CSS to add clear:both to the same selector, or use :after content if you really need to inject a styled block.



in general with these sort of problems, just try out different permutations in the firebug or dev tools console until you hit the tags you want.
There is nothing in CSS that will work with this. Only nth term which isn't backwards compatible so that is why I'm using Jquery.
CHEWX is offline   Reply With Quote