jquery声音没有播放

时间:2014-10-08 22:52:14

标签: jquery audio position

当div的x位置值超过50时,我想要播放声音。我用箭头键控制div。

http://jsfiddle.net/vvccvvcc/f9fsnLcu/3/

我猜测audioElement.play()无法正常工作。

声音和警报都不会弹出(函数playSound)

1 个答案:

答案 0 :(得分:0)

下面的固定代码 http://jsfiddle.net/f9fsnLcu/4/

First your sound handle was out of scope, so i defined it in window:
 window.audioElement = audioElement = blabla
Second you were trying to compare object with a number. Don't need to wrap x.left in jquery. 
if (x.left>50)