The I trying to change video id 8IYzyTYucKQ
to WKV_z36pVAk
dynamically but it is not changing.
I think the library bellow only work on page reload so when I clicked the button the new Id changes but the video play the older Id, when I reload the video again Id reset to default one.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>About</title>
<script type="text/javascript">
function val1(val)
{
location.reload();
document.getElementsByTagName("div")[0].setAttribute("data-video", val);
//document.getElementById("youtube-audio").data-video=val;
//document.getElementById("p1").innerHTML=val;
alert(val);
}
</script>
</head>
<body>
<h3 style="color:#0066dd">Hello</h3>
<center>
<div data-video="8IYzyTYucKQ"
data-autoplay="0"
data-loop="1"
id="youtube-audio">
</div>
</center>
<button onclick="val1('WKV_z36pVAk')">change</button>
</body>
<script src="https://www.youtube.com/iframe_api"></script>
<script src="https://cdn.rawgit.com/labnol/files/master/yt.js"></script>
</html>