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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:17:07+00:00 2026-06-14T15:17:07+00:00

Hi all i am working on jquery here i have my html like this

  • 0

Hi all i am working on jquery here i have my html like this
i want to move an image from one div to another div when check box selection it’s working but the question is i need to get back that image when i uncheck the
here my code follows

    <div class="grid row-fluid">
      <div>
        <span class="span1">                
        <input type="checkbox" class="regular-checkbox" id="Header" />
        <label for="Header"></label>                
        </span> 
        <span class="span1"> <img class="img-polaroid" src="http://placehold.it/140x140"></span> 
       </div>


         <div>
        <span class="span1">                
        <input type="checkbox" class="regular-checkbox" id="Header" />
        <label for="Header"></label>                
        </span> 
        <span class="span1"> <img class="img-polaroid" src="http://placehold.it/140x140"></span> 
       </div>
       </div>


       <div id="div2"></div>

this is my jquery

       $(function(){
  $('input[type="checkbox"]').click(function(){
    AddToCart(this);
  });
});

function AddToCart(obj) {
  var $this = $(obj).closest('div');
  var img = $this.find('img');
  $('#div2').append(img);
}

it’s workin need to get back those image checked when unchecked please help me to do this thanks in advance

  • 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-14T15:17:08+00:00Added an answer on June 14, 2026 at 3:17 pm

    try this one

    $('input').change(function(){
       if($(this).is(':checked')){
          var $this = $(this).closest('div');
          var img = $this.find('img');
          $('#div2').append(img);
     }
     else {
          var img = $('#div2').find('img');
          var $this = $(this).closest('div');
          $this.append(img);
     }
    });
    

    Code bug solved

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

Sidebar

Related Questions

Hi all i am working on jquery here i have my html like this
Hi all i am working on jquery here i have a html code like
new to jquery here, right now I have a working hide/show function when one
Hello all I am working on javascript jquery and svg.I want to ask a
I'm working with Jquery in Drupal. I have sets of four blocks that all
I have a jQuery dialog which loads an external php page. All is working
We have three developers and one tester all working against the same database. We
I have a draggable table which all working fine, though I want to be
All. I have been working on this for some time and can't seem to
So basically, im working in a rollover with jquery. i have regular html wrap

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.