nip*_*ese 2 jquery jquery-selectors
我试图编写一个if
语句来检查节点的父节点是否是三个选择器之一is()
,但是is()
不支持多个选择器作为参数.我怎样才能完成与此相似的事情?:
if ($(this).parent().is('.first','.second','.third')) {
//do this thing
} else {
//do this other thing
}
Run Code Online (Sandbox Code Playgroud)
.first, .second, .third
是一个有效的选择器:
$(this).parent().is('.first, .second, .third')
Run Code Online (Sandbox Code Playgroud)