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 7893015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:00:53+00:00 2026-06-03T07:00:53+00:00

Very simple JSFiddle demonstrates the problem (you’ll need to view a debug console since

  • 0

Very simple JSFiddle demonstrates the problem (you’ll need to view a debug console since console.log is used to demonstrate the problem). The 2nd console.log statement is empty. However the code works if I removeel from the following line:

var items = $('li[data-level="2"]', el);

so that it becomes:

var items = $('li[data-level="2"]');

then the code works. Can anyone explain why this is? Don’t know why the line declaring el would be missing, it’s showing for me in JSFiddle, but here’s all the code in the JavaScript panel:

$(document).ready(function() {
    var el = $('ul');
    var items = $('li[data-level="2"]', el);
    console.log(items);
    var visible = items.filter(':visible');
    console.log(visible);
});
  • 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-06-03T07:00:55+00:00Added an answer on June 3, 2026 at 7:00 am

    You have all of the li elements set to display:none, which is why el.filter(':visible') returns an empty collection. I’m not sure I see the problem here.

    jQuery’s $.filter method will return all of the items in the collection that match the selector passed into the filter. So if we were to select all list items, and strong items:

    $("li, strong");
    

    And then filter it so that we only have list items:

    $("li, strong").filter("li");
    

    Our result would only be list items. In your case, you have created an unordered list, replete with three hidden list items. You have selected all of these, and then attempted to filter them to only see those that are :visible, but since you hid them all with display:none in your CSS, the resulting collection will be empty.

    jQuery is worked as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having coded JavaScript since 1996, I have a very simple issue which I could
Fiddle demo available here: http://jsfiddle.net/r9MCW/5/ The functionality Basically, I have a very simple table
very simple problem, but i want to see how experts look at it. This
Here is a very simple example of what I have: http://jsfiddle.net/MxKLU/ Click on the
I wrote a very simple collision detection demo: http://jsfiddle.net/colintoh/UzPg2/5/ As you can see, the
I am trying to use a very simple implementation of the scrollTo plugin: http://jsfiddle.net/TPQyY/
Found this very simple code to show character counts for my text inputs: http://www.jamesfairhurst.co.uk/posts/view/jquery_word_character_counter
I have a very simple example that is not working. jsfiddle: http://jsfiddle.net/ThomasDeutsch/8hzhp/3/ // My
I have this very simple test view <button data-bind=click: add>Add</button> <table data-bind=foreach: items> <tr>
Ok, I'm very simply trying to take this example... http://jsfiddle.net/shanabus/HGF59/ and put it on

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.