Question

Je suis en train d'utiliser jQuery pour ajouter simplement une classe .alt à des blocs de article alternatifs dans un section principal comme suit:

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 quelque chose que je manque ...? Certes, cela devrait fonctionner!

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top