문제

Is this a valid syntax:

$("span").parents("li[data='UM'], li[data='Me']")

I want to traverse to parent of span and see if that parent is a li with value of data attribute as "UM" OR li with value of data attribute as "Me". Basically looking for OR operator in parents.

도움이 되었습니까?

해결책 2

use .closest() instead:

 $("span").closest("li[data='UM'], li[data='Me']")

다른 팁

Yes using closest() is definitely the right procedure.

$("span").closest("li[data='UM'], li[data='Me']");

http://api.jquery.com/closest/

if ($("span").closest("li").filter("li[data='UM'], li[data='Me']").length) { // there is... }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top