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

  • Home
  • SEARCH
  • 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 8952727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:56:18+00:00 2026-06-15T13:56:18+00:00

The .not() method takes either a selector or an object with which to filter.

  • 0

The .not() method takes either a selector or an object with which to filter.

The .contents() method returns a jQuery object containing the children and text nodes of an element.

When a selector is used as the argument for .not() it removes the selected elements but also all the text nodes.

When an object is used as the arguement for .not() it removes the object but not the text nodes.

Example:

<p>This is a <span id="aSpan">paragraph</span> tag</p>

$("p").contents().not("span");
> []

But!

var $sp = $("p span");
$("p").contents().not($sp);
> ["This is a ", " tag"]

also

var sp = document.getElementById("aSpan");
$("p").contents().not(sp);
> ["This is a ", " tag"]

Why are text nodes selected by the “span” selector (or any other selector) but not by an object instance?

  • 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-15T13:56:19+00:00Added an answer on June 15, 2026 at 1:56 pm

    The reason why this happens can be traced back to this particular edit, made 3 years ago. It unifies the .filter() and .not() methods, greatly simplifying both since they’re effectively each other’s opposites.

    Before the above edit, .not() would have called .filter() internally if the selector were anything but a string, so it would have operated on a filtered collection (i.e. .nodeType === 1) starting from this revision made 4 years ago.

    This means that – based on your code example – before the edit .not(object) would have returned an empty collection as well, which seems more logical than its current behavior.

    Now, both .not(object) and .filter(object) operate on the unfiltered collection, though only the former method will exhibit the behavioral difference.

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

Sidebar

Related Questions

Does the jQuery $.ajaxSetup method not respect the data field in the options hash
I have created a Webpage which will post as post method..not as get method.
I have a method that takes either a StringReader instance (reading from the clipboard)
Possible Duplicate: Object comparison in JavaScript Is there any method that takes in 2
If I have a method that takes either one or the other of two
How do I execute a foreach lambda expression on ObservableCollection<T>? There is not method
Via post (not get) method, i'mm getting id's in one file in php... How
I am getting a Method not found: 'Boolean MyCompany.LibraryAssembly.SomeFunction(System.String)' exception/error when running a VB.NET
java.lang.IllegalStateException: Could not execute method of the activity . I am new to Android.
I want to have the following method not show a warning about using raw

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.