javascript - remove() 方法在 animate() 中不起作用

标签 javascript jquery html css jquery-animate

在我的网页中,我有一些显示用户数据的 div。在某个事件中,我需要删除每个单击的 div。我想在删除 div 之前让它更漂亮一些。
所以我使用了 animate 方法并在 animate 方法的内部回调中编写了代码以从 dom 中删除该 div。 但问题是它表明不能对 null 调用 remove。 animate 方法如何在该 div 上运行并在其回调中变为 null。
请帮助我解决问题,并建议是否有更好的方法。

    confirmOpen = //Holding reference of div to be removed.
    //animate method is running perfectly fine.
    confirmOpen.animate({"width":"1px","height":"1px"},500,function()
    {
       console.log(confirmOpen); //Logging null
       confirmOpen.remove();   //Showing error that remove method cannot be called on a null value.
    });  

最佳答案

我认为在变量confirmOpen 中设置引用时存在一些错误。 您不能删除空值。

关于javascript - remove() 方法在 animate() 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18692067/

相关文章:

javascript - 如何从零开始轴标签?

javascript - 如果第二个子元素为空,jQuery 删除页面上的多个类

java - GWT。删除 anchor 部分 url

jquery - 到达正文末尾后,向下滚动不会重复

javascript - 阻止 jQuery 调用下一个事件

html - 复选框 - 用 fa-link 替换复选标记

html - 全宽背景响应式网站

javascript - 如何防止 img src 无效,如果无效则保留以前的图像

php - JQuery 运行速度太快?

javascript - Marionette - "startWithParent = false"会导致什么?