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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:02:09+00:00 2026-06-09T03:02:09+00:00

Why is there a filter function in jQuery when you can get and show

  • 0

Why is there a filter function in jQuery when you can get and show / hide the elements by class?

$('.yourClass');
  • 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-09T03:02:11+00:00Added an answer on June 9, 2026 at 3:02 am

    Just because you have some elements that you’d like to work with doesn’t mean that they’re in the DOM. Consider this contrived example:

    var $els = $('<div class="a"></div><div class="b"></div>');
    console.log($('.a'));
    console.log($els.find('.a'));
    console.log($els.filter('.a'));​
    

    Demo: http://jsfiddle.net/ambiguous/h3GMB/

    The first one, $('.a'), gives you nothing because $els aren’t in the DOM yet. The second one also gives you nothing because find searches descendents. Only the third one will give you what you’re looking for because filter reduces:

    the set of matched elements to those that match the selector […]

    This sort of manipulation of things not in the DOM is fairly common when preparing template chunks for the DOM. The difference between filter and find is also fairly important even when the elements in question are in the DOM.

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

Sidebar

Related Questions

I am trying to build a simple jQuery filter system to show and hide
Is there some function in haskell that evaluates to (filter p xs, filter (not.p)
Is there an ISAPI filter that can automatically add the Last-Modified header in IIS?
Is there a way construct a predicate to filter by class type? I currently
Is there any way to get jQuery Support / Intellisense in T4-Templates? In normal
How can I get the nearest next element that sattisfies some condition/function? Like: nextEl
I create a function of jquery that get the value from the select box,
Is there any built-in function in Python3/Numpy which filters an array and returns indices
Is there a way to filter or follow a TCP / SSL stream based
Is there a difference between filter and exclude in django? If I have self.get_query_set().filter(modelField=x)

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.