I want to remove only those ul with li that doesn’t have a custom attribute on it. I was trying this
$myParent.children('li ul:not("ul[isClicked=True]")').remove();
but can’t get it to work. Any help would be appreciated.
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.
If I understand you correctly, you want to remove theuls that containlis with the attributeisClicked="True":Note that the attribute must contain the word
"True"; it’s a string, not a boolean.Live example
From your comment below:
That’s the opposite of the opening sentence of your question (“I want to remove only those ul with li that have a custom attribute on it”). 🙂 Here’s how you’d do that assuming the
ulelements are direct children of$myParent(your example code suggests this); if that’s not true, just change the.childrenon the first line to.find:Live example
FWIW, that attribute name won’t validate. You might consider switching to the
data-*attribute form.