1

私は3つのdivを持っています:

<div class='squares' id='div1'></div>
<div class='squares' id='div2'></div>
<div class='squares' id='div3'></div>

jQuery を使用して、最初の div を除くすべての div に css プロパティ (border-right) を適用したいと考えています。

使用する必要がある if ステートメントは何ですか? if ステートメントでクラスを使用したい (id ではありません)。

どうもありがとう。

4

3 に答える 3

5

:not()および:firstセレクターを使用できます。

$('.squares:not(:first)').addClass('border')

また:

$('.squares:not(:first)').css('border-right', 'value')
于 2012-08-04T02:59:13.437 に答える