Discuss / JavaScript / 作业

作业

Topic source

dante0009

#1 Created at ... [Delete] [Delete and Lock User]

动画执行是异步的,所以要把删除写在回调里

tr.fadeOut('slow', function(){$(this).remove();})

廖雪峰

#2 Created at ... [Delete] [Delete and Lock User]

概念理解到位 √

壮丁宇素

#3 Created at ... [Delete] [Delete and Lock User]

不太明白,为什么写tr.fadeOut(3000).remove()不可以呢?

因为动画执行需要一段过程,如果后面紧跟着remove,那么它立马就直接执行了,就看不到渐变过程了。所以需要等动画过程完成后再调用删除命令。

colorsumer

#5 Created at ... [Delete] [Delete and Lock User]

我也明白,那为什么写tr.fadeOut(3000).fadeIn(3000)就可以呢?

想问一下我自己直接用tr.fadeOut('slow');也可以直接实现该功能,为何需要回调函数再删除一下呢。

廖雪峰

#7 Created at ... [Delete] [Delete and Lock User]

fadeOut是隐藏,隐藏不等于删除

sheyu小于

#8 Created at ... [Delete] [Delete and Lock User]

tr.fadeOut('slow', ()=>$(this).remove())

请教一下,为什么我用箭头函数代替达不到删除的效果,什么地方出错了.

强新宇_iOS

#9 Created at ... [Delete] [Delete and Lock User]
tr.fadeOut('slow',() => $this.remove());

强新宇_iOS

#10 Created at ... [Delete] [Delete and Lock User]

这样也可以,好像不用再转一次jQuery对象

tr.fadeOut('slow',() => this.remove());

  • 1
  • 2

Reply