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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:53:32+00:00 2026-05-26T02:53:32+00:00

How do i use jQuery to add and remove item from unordered lists? When

  • 0

How do i use jQuery to add and remove item from unordered lists?
When i doubleclick on an item in list 1 it should be removed from list 1 and added to list 2
And of course, the other way around as well…

I’ve got the following lists:

<ul id='attached'>
  <li id='itemID_1' ondblclick='removeAttached(&#39;itemID_1&#39;)'>Item</li>
  <li id='itemID_2' ondblclick='removeAttached(&#39;itemID_2&#39;)'>Item</li>
  <li id='itemID_3' ondblclick='removeAttached(&#39;itemID_3&#39;)'>Item</li>
  <li id='itemID_4' ondblclick='removeAttached(&#39;itemID_4&#39;)'>Item</li>
</ul>

<ul id='non-attached'>
  <li id='itemID_5' ondblclick='addAttached(&#39;itemID_5&#39;)'>Item</li>
  <li id='itemID_6' ondblclick='addAttached(&#39;itemID_6&#39;)'>Item</li>
  <li id='itemID_7' ondblclick='addAttached(&#39;itemID_7&#39;)'>Item</li>
  <li id='itemID_8' ondblclick='addAttached(&#39;itemID_8&#39;)'>Item</li>
</ul>

I was thinking something like:

<script type='text/javascript'>")
  function addAttached(i) { $('#non-attached').remove(i); $('#attached').append(i); };")
  function removeAttached(i) { $('#attached').remove(i); $('#non-attached').append(i); };")
</script>")

But i might be pretty off here?

  • 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-05-26T02:53:32+00:00Added an answer on May 26, 2026 at 2:53 am

    If you want to move things back and forth, your best bet is event delegation:

    <ul id='attached'>
        <li id='itemID_1'>Item</li>
        <li id='itemID_2'>Item</li>
        <li id='itemID_3'>Item</li>
        <li id='itemID_4'>Item</li>
    </ul>
    
    <ul id='non-attached'>
        <li id='itemID_5'>Item</li>
        <li id='itemID_6'>Item</li>
        <li id='itemID_7'>Item</li>
        <li id='itemID_8'>Item</li>
    </ul>
    

    JS

    $("#attached").delegate("li", "dblclick", function() {
        $("#non-attached").append(this);
    });
    
    $("#non-attached").delegate("li", "dblclick", function() {
        $("#attached").append(this);
    });
    

    This will detect a click on an li element which bubbles up to your list. Then it will move the element to the other list.

    JSFiddle: http://jsfiddle.net/TYwPU/

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

Sidebar

Related Questions

I'm trying to use jQuery to add dynamic Add/Remove row function, but I meet
I'm trying to use JQuery to add/remove classes as part of a function that
How do I use jQuery validator to add/remove a classname (e.g. validate ) on
I would like to use jQuery to dynamically add and remove sections of html
Hi i use the following simple jquery script to append input. Source http://muiomuio.com/web-design/add-remove-items-with-jquery <html
I currently have javascript/jquery to 'add and remove' steps from a set of instructions
I would like to use jquery to build a dynamic add/ remove form. IT
Currently we use jQuery to add RIA goodness to our apps, but recently we
I want to use jquery to add a rel=shadowbox to a <a> tag How
I'm using (trying to use) jQuery to add a class to the first paragraph

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.