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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:27:54+00:00 2026-06-16T10:27:54+00:00

I have a seemingly very simple problem, but my bandwidth is so limited by

  • 0

I have a seemingly very simple problem, but my bandwidth is so limited by now, and have searched SO but found a relevant question only applied to C#, I meant no luck yet.

HTML:

<ul class="first">
  <li data-id="1">One</li>
  <li data-id="2">Two</li>
  <li data-id="3">Thre</li>
  <li data-id="4">Four</li>
  <li data-id="5">Five</li>
  <li data-id="6">Six</li>
</ul>
<ul class="second">
  <li data-id="1">One</li>
  <li data-id="2">Two</li>
  <li data-id="3">Thre</li>
  <li data-id="4">Four</li>
</ul>

I want to remove the last 2 items from the first (hence Five and Six), because they do not exist in the second. Order is not important actually. The sample to simplify my problem.
Basically no clear idea to achieve this, sorry, so whenever I tried with .length check, I remove all the first items.

Any hint is very much appreciated. Thanks

UPDATED:
Sorry my bad.
“Order is not important actually”: I meant the lists may be unordered like:

<ul class="second">
  <li data-id="3">Thre</li>
  <li data-id="1">One</li>      
  <li data-id="4">Four</li>
  <li data-id="2">Two</li>
</ul>

Also applies to the first.

  • 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-16T10:27:55+00:00Added an answer on June 16, 2026 at 10:27 am

    If you’re assessing equivalence by the data-id attribute:

    $('.first li').filter(
        function(){
            return !$('.second li[data-id="' + $(this).data('id') + '"]').length;
        }).remove();​
    

    JS Fiddle demo.

    References:

    • data().
    • filter().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a seemingly simple problem, but I can't quite figure out a solution.
I have a seemingly very small problem, but I can't find a solution for
I have a seemingly simple problem, but an easy solution is alluding me. I
So, this is a seemingly simple question, but I'm apparently very very dull. I
I have a seemingly simple problem whereby I wish to reconcile two lists so
Forgive me for this seemingly obvious question, but my searches have not revealed the
I am trying to implement something seemingly very simple, and I have been beating
I have a seemingly very basic question. I'm trying to decide whether or not
Seemingly a very simple thing to do but it took me >30min without finding
I'm stuck on a RegEx problem that's seemingly very simple and yet I can't

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.