remove() 方法在 animate() 中不起作用
remove() method not working inside animate()
在我的网页中,我有一些div显示用户的数据。在某个事件中,我需要删除单击的每个div。我想在删除div 之前让它更漂亮一点。
所以我使用了 animate 方法和 animate 方法的内部回调,我编写了代码以从 dom 中删除该div。 但问题是它表明不能在 null 上调用 delete。动画方法如何在该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 中设置引用时存在一些错误。不能删除空值。
confirmOpen
confirmOpen.animate({"width":"1px","height":"1px"},500,function()
{
将导致错误,因为该函数中没有变量声明,并且您正在删除相同的confirmOpen
因此您应该只使用$(this).remove();
confirmOpen = //Holding reference of div to be removed.
confirmOpen.animate({"width":"1px","height":"1px"},500,function()
{
console.log(confirmOpen);
$(this).remove();
});
I hope it will work but can you send js fiddle example for more effective results
相关文章:
- $animate addClass在angular 1.3中不起作用
- jQuery Animate 在创建图库滑块时不起作用
- css animate fadeIn'对我来说不起作用
- Javascript/JQuery .animate() 不起作用
- $animate.removeClass 在没有 $evalAsync inside 指令的情况下不起作用
- jQueryUI animate(color) 不起作用
- $(“html”).animate 不起作用
- JS .animate() 在 Firefox/IE 中不起作用
- css JQuery animate 不起作用
- Jquery ui animate 函数不起作用
- jQuery animate:scrolltop 在 Firefox 或 Web Explorer 中不起作用
- jQuery animate() 在 Chrome 中不起作用
- jquery Animate 在 IE9 及更早版本中不起作用
- remove() 方法在 animate() 中不起作用
- jQuery animate() pulse() 不起作用
- JQuery animate获胜'不起作用
- Jquery.animate 100%高度不起作用
- 当从外部方法调用时,RaphaelJS的animate不起作用
- Jquery .animate()用于左右滚动在Firefox中不起作用,但在Chrome中很好
- jQuery animate根本不起作用