2

ifノードの親が を介して 3 つのセレクターの 1 つであることを確認するステートメントを作成しようとしていますがis()is()複数のセレクターを引数としてサポートしていません。これに似たものをどのように達成できますか?:

if ($(this).parent().is('.first','.second','.third')) {
    //do this thing
} else {
    //do this other thing
}
4

2 に答える 2

6

.first, .second, .third有効なセレクタです:

$(this).parent().is('.first, .second, .third')
于 2013-07-01T06:02:03.340 に答える
1

のAPI ドキュメントのis()例を確認してください。

コンマ区切りのリストを指定できます。

if ($(this).parent().is('.first,.second,.third')) {
    //do this thing
} else {
    //do this other thing
}
于 2013-07-01T06:04:27.377 に答える