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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:56:39+00:00 2026-06-10T23:56:39+00:00

According to here , jquery’s remove function should work like so.. $(‘div’).remove(‘selector’); Which I’m

  • 0

According to here, jquery’s remove function should work like so..

$('div').remove('selector'); 

Which I’m trying in this example.

HTML:

<div class="wrapper">
    <p class="unwanted">This should be removed</p>
    <p class="retained">This will remain</p>
</div>​

JavaScript:

jQuery(document).ready(function($) {
    $('div').remove('p.unwanted'); //not working
    //$('p.unwanted').remove(); //this works
});

​
It’s not working. What am I doing wrong?

  • 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-10T23:56:40+00:00Added an answer on June 10, 2026 at 11:56 pm

    You’ve misunderstood what the documentation is saying. It’s not looking for elements that are descendants of the matched elements that match the selector, it’s simply filtering down the set of already matched elements to those that match the selector, and then removing them.

    If you have this HTML:

    <div class="wanted">Some text</div>
    <div class="wanted">Some more text</div>
    <div class="unwanted">Some unwanted text</div>
    

    and then executed this jQuery:

    $('div').remove('.unwanted');
    

    then it would only remove that third <div> (the one with the unwanted class on it), because it first selects all <div> elements, and then only removes those that match the selector.

    Example jsFiddle

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

Sidebar

Related Questions

I am trying to use the jQuery CSV plugin, as documented here: http://code.google.com/p/js-tables/wiki/CSV According
I am using JQuery Accordion. I have this page here: http://www.hauppauge.com/site/support/support_colossus.html#tabs-6 What happens is
According to the discussion comments here: http://api.jquery.com/append/ the .append() of a script evaluates the
I am using following a tutorial from here: http://www.shopdev.co.uk/blog/cookies-with-jquery-designing-collapsible-layouts/ This is the script I
Here is my relevant jQuery code: $.get('sampleData.csv', function(data) { var lines = data.split('\r\n'); The
I am implemented a jQuery UI sortable element. Here is my code: $(function() {
I want to make drop-down menu with jquery (here's the according jsFiddle ). HTML:
I'm using this jQuery Full Calendar: http://arshaw.com/fullcalendar/ According to their documentation, I can load
I have a basic plugin written according the jQuery authoring guide . This plugin
Going slightly crazy here. I'm making an Ajax call using jQuery.post as follows: $.post('php/print.php',{data:dS},function(res){...

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.