0

我正在尝试使用 jQuery 将一个.alt类简单地添加到 main 中的备用articlesection,如下所示:

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');

我错过了什么……?当然这应该工作?!

4

1 回答 1

0

上面的代码确实有效,我的 jQuery 文件中的其他内容抛出了问题。请参阅上面的评论。

于 2013-08-21T14:39:48.950 回答