简体   繁体   English

jQuery-移动Div

[英]Jquery - Move Div around

I am using Jquery Drag and drop to move divs across a page and this works perfectly. 我正在使用Jquery拖放来在整个页面上移动div,因此效果很好。 however what i would like is on each one of the div containers is to have a close button which when clicks removes the div from where it is and places it in a pre-defined div at the bottom like a widget gallery. 但是,我想要的是每个div容器上都有一个关闭按钮,单击该按钮可将div从其所在位置移除,并将其放置在底部的预定义div中,例如小部件库。

How would this be accomplished? 这将如何实现? - below is my html.. thanks -以下是我的html ..谢谢

Chris 克里斯

<div class='column' id='leftcolumn'></div>

<div class='column' id='rightcolumn'>

    <div class='dragbox'>
      <span class='close'>Close</span>
Content In here
    </div>
</div>

<div class='column' id='widgetgallery></div>
$('div.dragbox > span.close').click(function(){
  $(this).parent().appendTo("#widgetgallery");
});

Try: 尝试:

$('.close').click(function(){
  $('#widgetgallery').append($(this).parent());
  $(this).parent().delete();
});

I dunno if the appending part will work tough. 我不知道附加部分是否会正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM