use .closest()
instead:
$("span").closest("li[data='UM'], li[data='Me']")
Question
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.
Solution 2
use .closest()
instead:
$("span").closest("li[data='UM'], li[data='Me']")
OTHER TIPS
Yes using closest() is definitely the right procedure.
$("span").closest("li[data='UM'], li[data='Me']");
if ($("span").closest("li").filter("li[data='UM'], li[data='Me']").length) { // there is... }