Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4621932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:46:20+00:00 2026-05-22T02:46:20+00:00

Here is the sample html I have. <ul id=alist> <li class=red>…</li> <li class=blue>…</li> <li

  • 0

Here is the sample html I have.

<ul id="alist">
<li class="red">...</li>
<li class="blue">...</li>
<li class="red">...</li>
<li class="green">...</li>
</ul>

Aim: To select all the elements in the list which don’t have ‘red’ class and fade them out.

This is what I have so far. I know it’s close, but either there’s a bug in the code or in the selector somewhere.

$('#alist :not(:has(.red))').fadeOut('slow');

I also tried

$('#alist li :not(:has(.red))').fadeOut('slow');

$('#alist :not(:has(li.red))').fadeOut('slow');

None of them are working (obviously). But when I tried to filter something inside the ul it does. So with a html as:

<li><a class="red">...</li>
.
.
.
<li><a class="green">...</li>

and made the jquery selector

$('#alist li :not(:has(a.red))').fadeOut('slow');

it works.

So why isn’t JQuery not letting me filter li classes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:46:21+00:00Added an answer on May 22, 2026 at 2:46 am

    :has looks at the children of elements. You just need to look at the element’s class itself. So:

    $('#alist :not(.red)').fadeOut('slow');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A sample of the HTML snippet is here: <select name=paytitle id=paytitle> <option value=Budget Keeper
I have some content sliding here. http://www.smallsharptools.com/downloads/jQuery/Slider/slider.html The HTML structure is simple. There is
Here is a sample code: public class TestIO{ public static void main(String[] str){ TestIO
I have html list <ol id=newlist> <li>Test <ol> <li>1</li> <li>2</li> <li>3</li> </ol> </li> <li>Another
I have a list of URLs, each page is a specific category: http://www.site.com/category-1/page.html http://www.site.com/category-2/page.html
I am trying to reuse Apple's Speak Here sample code in my own iPhone
Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document()
Here is a sample from Kernighan & Ritchie's The C Programming Language: int getline(char
Here is a sample code to retrieve data from a database using the yield
Here is the sample: Dim TestString As String = Hello, & Chr(0) & World

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.