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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:46:00+00:00 2026-05-12T06:46:00+00:00

I have a web page that contains two lists (Unorders lists), I have to

  • 0

I have a web page that contains two lists (Unorders lists), I have to move items from list 1 to list 2 but to filter out items that are already in list 2.
I’m using JQuery as js library. I know I can select all items to be moved to list 2, loop one by one and check if alredy exists in list 2, but was wandering if there is a way to do it in less lines of code using filter, :not, :has …
Here is a html structure:

  <ul id="ulList_1">
     <li>
        <a href="#">item 1</a>
     </li>
     <li>
        <a href="#">item 2</a>
     </li>
  </ul>

  <ul id="ulList_2">
     <li>
        <a href="#">item 2</a>
     </li>
     <li>
        <a href="#">item 3</a>
     </li>
     <li>
        <a href="#">item 4</a>
     </li>      
 </ul>

So, in this scenario I want to select only “item 1” since “item 2” already exists in “ulList_2”, and append it to list 2
Thanks

  • 1 1 Answer
  • 3 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-05-12T06:46:00+00:00Added an answer on May 12, 2026 at 6:46 am

    I would extract first the innerText of the elements of your list 2 to an array using $.map, and then filter the list 1, selecting only the non-existing elements of list 2 using $.inArray:

    var list2Items = $('#ulList_2 li > a').map(function(){return $(this).text();}); 
    // list2Items will be: ["item 2", "item 3", "item 4"] 
    
    var itemsNotInList2 = $('#ulList_1 li > a').filter(function(){
      return $.inArray($(this).text(), list2Items) == -1; // Select only non-existing
    });                                                   // items.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that contains two articles. Upon loading this page, jQuery
I have a web page that contains two textboxes and a button. I can't
Say we have an overlay DHTML panel on a web page that contains two
I have a ASP.NET web page that contains many textboxes. Each textbox has a
I have a web page that displays a list of documents stored on the
On a web page I have a quite large list of items (say, product
I have a div that contains a form with two drop down lists in
new on rails and using windows for now,, i have web page that user
I have web forms page that has 2 controls. A gridview and an associated
I have a web page that prompts for user input via DropDownLists in some

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.