So I want to check if there is any li element that has a attribute of “data-foo” and its value is “bar”.
Would this work? :
if ($('li[data-foo=bar]'))
{
//exists
}
else
{
//does not exist
}
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Get
lengthof elements retured by selector if it isgreaterthenzerothen it means you haveatleast oneelement with provided condition in selector.