几个div,想remove掉前面的一个,后面的div怎么做一个移动的动画,不想要直接就过去的那种

qq_15350787 2017-03-30 09:55:09
如题如题字数字数字数
...全文
175 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
文盲老顾 2017-03-31
  • 打赏
  • 举报
回复

function removeDiv(id){
   var target = $('#'+id);
   var next = target.next();
   var h = next.position().top - target.position().top;
   target.css({position:'absolute','z-index':'-1'});
   next.css({'margin-top':h+'px'});
   next.animate({'margin-top':'0px'},200).prev().remove()
}
文盲老顾 2017-03-31
  • 打赏
  • 举报
回复
获取要remove的div的position(),然后获取remove对象后一个div的position(),取两个position之间的高度差,然后设置要remove的div的position样式为absolute,z-index数小一些,后边的div的margin-top加上高度差,然后缩减margin-top到高度差为零结束

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧