为什么第一个代码块工作而第二个代码块不工作?--
以下代码有效:-
// this code works --
<script src=".../popcorn-complete.min.js"></script>
var time_prompts = new Array();
time_prompts[0] = 2 //any integer < video duration
$popcorn.on( "timeupdate", function() {
console.log( this.currentTime() );
if (this.currentTime() > time_prompts[0] && this.currentTime() < time_prompts[0]+0.1) {
this.pause();
console.log(this.paused)
}
});
虽然以下代码不起作用:-
// this code DOES NOT work
<script src=".../popcorn-complete.min.js"></script>
var time_prompts = new Array();
time_prompts[0] = 2 //any integer < video duration
$popcorn.on( "timeupdate", function() {
console.log( this.currentTime() );
if (this.currentTime() == time_prompts[0]) {
this.pause();
console.log(this.paused)
}
});
(两个代码块之间的唯一区别是'if语句'(条件))