Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 根据媒体正在播放还是暂停更改按钮的文本?_Javascript_Html_Audio_Video - Fatal编程技术网

Javascript 根据媒体正在播放还是暂停更改按钮的文本?

Javascript 根据媒体正在播放还是暂停更改按钮的文本?,javascript,html,audio,video,Javascript,Html,Audio,Video,我的代码部分工作。当我单击“播放”时,它会变为“暂停”,但当我单击“暂停”后,它会保持为“暂停”,而不会变回“播放” var playOrPause = function (id, button) { var pp = document.getElementById(id); if(pp.paused) { button.textContent = 'Play'; } else if(!pp.paused) { button.textContent

我的代码部分工作。当我单击“播放”时,它会变为“暂停”,但当我单击“暂停”后,它会保持为“暂停”,而不会变回“播放”

var playOrPause = function (id, button) {
var pp = document.getElementById(id);
    if(pp.paused) {
        button.textContent = 'Play';
    } else if(!pp.paused) {
        button.textContent = 'Pause';
    }
};
我刚刚解决了我的问题。我把我的一个活动听众的代码编错了哈哈,谢谢你们的帮助

$('.player_audio').click(function() {if (this.paused == false) { this.pause();
  alert('music paused'); } else { this.play();alert('music playing');}});

如果(pp.paused){button.textContent='Play';}或者{button.textContent='Pause';},这将帮助您

为什么不
呢?
我试过了,它仍然不起作用:/Share完整的代码,包括标记和您调用函数的方式。。它不会让我上传整个内容。它说,这不是代码,我需要添加更多的细节我明白了,但谢谢你的帮助!var playOrPause=function(id,button){var pp=document.getElementById(id);if(pp.paused){button.textContent='Play';}否则if(pp.Play){button.textContent='Pause';};你的病情一直在恶化。甚至玩或暂停。因此,条件不起作用,请检查您是否有语句。您可以将代码放入JSFIDLE中,以便我可以解决它。从未使用过JSFIDLE。只需设置一个帐户并输入代码,但我如何共享它?转到你的帐户->单击你的公共小提琴->粘贴你的代码。保存它。复制url并发送给我