html脚本怎么触发,在HTML中使用“onkeypress”触发视频,但是只有脚本中的最后一个代码会触发视频并且不确定为什么...

我对编程相当陌生,并且很难弄清楚为什么它不起作用。脚本中的两个代码都能正常工作,但是当放在一起时,只有最后一个代码可以工作。

代码:

var video1 = document.getElementById("clap-test");

document.onkeypress = function(e) {

if ((e || window.event).keyCode == "83") {

video1.currentTime = 0, video1.play();

}

};

var video2 = document.getElementById("chord-1");

document.onkeypress = function(e) {

if ((e || window.event).keyCode == "65") {

video2.currentTime = 0, video2.play();

}

};

#backplate {

position: absolute;

top: 0;

left: 0;

min-height: 100%;

min-width: 100%;

z-index: -4;

}

#twinkle {

position: absolute;

top: 0;

left: 0;

min-height: 100%;

min-width: 100%;

z-index: -3;

mix-blend-mode: screen

}

#skel-walk {

position: absolute;

top: 0;

left: 0;

min-height: 100%;

min-width: 100%;

z-index: -1;

mix-blend-mode: screen;

}

#clap-test {

position: absolute;

top: 0;

left: 0;

min-height: 100%;

min-width: 100%;

z-index: 0;

mix-blend-mode: screen;

}

#chord-1 {

position: absolute;

top: 0;

left: 0;

min-height: 100%;

min-width: 100%;

z-index: -2;

mix-blend-mode: screen;

}

Back_Plate00000.png

Video not supported

Video not supported

Video not supported

Video not supported

2017-08-07

ThomTTP

+0

@rabbit guy嗨对不起,我的错误,我认为它是Java的一部分,生病删除标签 - 新的所有这一切!你有什么建议可能是什么问题? –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值