0

.alt次のように、jQueryを使用して、メイン内の代替articleブロックにクラスを追加しようとしてsectionいます:

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 に答える