如何(移动)或使用jquery从一个div到另一个div添加jpg'Image'? [英] How to (move) or Add an jpg 'Image' from one div to another div using jquery?

查看:137
本文介绍了如何(移动)或使用jquery从一个div到另一个div添加jpg'Image'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我在jquery这里工作我有这样的html

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

            <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 class="span7" style="border:1px black" id="separate">

                <ul class="thumbnails bootstrap-examples pre-scrollable">
                    <li class="span2">
                      <a href="#">
                        //image shold add here
                      </a>
                      </li>
                     </ul>
         </div>

在上面的代码我有一个图像和复选框确定现在我有一个空div现在我想将这些图像添加到empye div一次
i选择它只检查图像

in the above code i have a images and checkbox ok now i have one empty div now i want to add those image to the empye div once i select it the checked images only

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

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

如何使用jquery将图像从一个div添加到另一个div可以帮助你我提前感谢

how to add image from one div to another div using jquery could u plz help me to do this thanks in advance

推荐答案

这是你可以做的:

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

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

这篇关于如何(移动)或使用jquery从一个div到另一个div添加jpg'Image'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆