level 3
Noobl℉
楼主
这一段js是什么意思
function boom(callback){
//var that=this; //替换了上下文,但是没有使用this的意义.
var speed=this.getAttribute('speed');
this.timer=setInterval(function(){
this.style.opacity=0.1*(speed--)
if(speed<1){
if(this.parentNode){
this.parentNode.removeChild(this);
bnElements.splice(bnElements.lastIndexOf(this),1);
callback&&callback();
}
clearInterval(this.timer);
}
}.bind(this),30);
}
</script>

2018年12月20日 07点12分
1
function boom(callback){
//var that=this; //替换了上下文,但是没有使用this的意义.
var speed=this.getAttribute('speed');
this.timer=setInterval(function(){
this.style.opacity=0.1*(speed--)
if(speed<1){
if(this.parentNode){
this.parentNode.removeChild(this);
bnElements.splice(bnElements.lastIndexOf(this),1);
callback&&callback();
}
clearInterval(this.timer);
}
}.bind(this),30);
}
</script>
