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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:09:11+00:00 2026-05-13T22:09:11+00:00

Item 1 <div id=i2><span id=e2>Item 2</span></div> When I click on Item 1 it should

  • 0

Item 1

<div id=i2><span id=e2>Item 2</span></div>

When I click on Item 1 it should be deleted and moved to i2 and when I click on Item 1 again it must go back to i1

Yes, I tried append(), it goes to i2, but on clicking again it does not move back to i1

How do I get to do it.

Thanks
Jean

  • 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-13T22:09:12+00:00Added an answer on May 13, 2026 at 10:09 pm
    <script type="text/javascript">
    $(function(){
    
        $("#i1").toggle(function(){
            $("#e1").appendTo("#i2");
        },
        function(){
            $("#e1").appendTo($(this));
        }); 
    });
    </script>
    <div id=i1><span id="e1">Item 1</span></div>
    <div id=i2><span id="e2">Item 2</span></div>
    

    This will repeat the actions for the two clicks. For the first click e1 will be appended to i2, for the second click reverse of this happens, and third click it will repeat first click action and so on.

    If you want to attach click event to the span then you can do like this

    $("#e1").toggle(function(){
            $(this).appendTo("#i2");
        },
        function(){
            $(this).appendTo($("#i1"));
        });
    

    If you have repeating elements then you can give them a class name

    <script type="text/javascript">
    $(function(){
    
        $("span.clickspan").toggle(function(){
            $(this).appendTo("#i2");
        },
        function(){
            $(this).appendTo($("#i1"));
        }); 
    });
    </script>
    <div id=i1>
        <span id="e1" class="clickspan">Item 1</span>
        <span id="e2" class="clickspan">Item 1</span>
        <span id="e3" class="clickspan">Item 1</span>
        <span id="e4" class="clickspan">Item 1</span>
        <span id="e5" class="clickspan">Item 1</span>
    </div>
    <div id=i2><span id="e6">Item 2</span></div>
    

    See a working demo.

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

Sidebar

Related Questions

So if I call this function: $(#item).text() on this HTML code: <div id=item> <pre><span
I'm trying to animate the div within an list item with a click event
<li> <h4 class=title-exp-coll title-expand> <span class=exp-coll></span>Bookmarks</h4> <div class=item-list> <ul> <li class=first><div>first Asset</div></li> <li><div>Latest Updates</div></li>
I start with this markup: <div> <span> <label for=Item[0]>Item #1</label> <input type=text value= name=Item
I have this code: $(function(){ $('body').append('<div id=tooltipMaterials><span id=arrow></span><div id=inside></div></div'); var $tooltip = $('#tooltipMaterials'); $tooltip.hide();
I have this menu: <ul id=nav> <li class=level0>Item 1</li> <li class=level0 parent> <a><span>Click Me!</span></a>
I have the following code: <div class=topLevel> <span class=misc pointDown></span> <span class=misc></span> <span class=b>item</span>
This is my JavaScript code: // action when item file is clicked $(li span.file).click(function(){
Page has menu items that would replace a 'div id=foo_(current menu item)' with 'div
I can select the first item in the div using $('.class:first') Now since I

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.