javascript - 这段代码中,jquery中promise done方法为什么无效呢?
PHPz
PHPz 2017-04-11 11:25:20
0
1
332
setTimeout(function(){
$("p.A,p.B").fadeOut(500).promise().done(showIntroSection);
            function showIntroSection(){
            console.log("delay");
                $("p.C").animate({"opacity":"1","width":"70%"},10000).promise().done(console.log("1"));
            }
        },1000);
  

如上代码,对p.A,p.B执行了fade()方法后,500ms延迟后可以正常的输出delay,表示第一个promise done方法成功,但是在done方法的showIntroSection函数内部,p.C的动画确是和console.log("1")同时执行的,
问题在于 showIntroSectin函数中,不是应该先执行完10000ms的动画,再输出这个console.log("1")的吗?
这个promise done方法为什么无效呢?
(试过改成when then什么的,都是一样的症状)
不明白问题出在哪里 希望大家给些帮助

PHPz
PHPz

学习是最好的投资!

Antworte allen(1)
巴扎黑

虽然我没写过jquery..但是听问题描述和看代码感觉
我觉得你把
$("p.C").animate({"opacity":"1","width":"70%"},10000).promise().done(console.log("1"));
中的
console.log("1")
改成
function(){console.log("1")}
应该就可以了。

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!