Question

I'm trying to use jQuery to simply add an .alt class to alternate article blocks within a main section as follows:

html5:

<section id="content" role="main">

  <h1>Main Title</h1>

  <article id="post-1" class="post-1 post type-post">
    .. article content ..
  </article>

  <article id="post-2" class="post-2 post type-post">
    .. article content ..
  </article>

  <article id="post-3" class="post-3 post type-post">
    .. article content ..
  </article>

</section>

jQuery:

$('#content article:nth-child(odd)').addClass('alt');

Am I missing something...? Surely this should work?!

Was it helpful?

Solution

The above code does work, other content in my jQuery file was throwing out problems. See the comments above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top