if
ノードの親が を介して 3 つのセレクターの 1 つであることを確認するステートメントを作成しようとしていますがis()
、is()
複数のセレクターを引数としてサポートしていません。これに似たものをどのように達成できますか?:
if ($(this).parent().is('.first','.second','.third')) {
//do this thing
} else {
//do this other thing
}
if
ノードの親が を介して 3 つのセレクターの 1 つであることを確認するステートメントを作成しようとしていますがis()
、is()
複数のセレクターを引数としてサポートしていません。これに似たものをどのように達成できますか?:
if ($(this).parent().is('.first','.second','.third')) {
//do this thing
} else {
//do this other thing
}
.first, .second, .third
有効なセレクタです:
$(this).parent().is('.first, .second, .third')
のAPI ドキュメントのis()
例を確認してください。
コンマ区切りのリストを指定できます。
if ($(this).parent().is('.first,.second,.third')) {
//do this thing
} else {
//do this other thing
}