내 자바 스크립트를 내 html 오디오 소스로 변경하고 싶습니다. stackoverflow에서 검색했지만 원하는 항목을 찾을 수 없습니다.자바 스크립트가 변경된 음악 소스
이것은 내 HTML 코드입니다. 나는이 순간에 CSS를 사용하지 않았다. 나는 buttonclick에 음악 변경을 할
/**
* Created by Jasper on 12-1-2017.
*/
var currentsong = document.getElementById('currentsong');
var nextbutton = document.getElementById('songbutton');
currentsong = 1;
currentsong = 2;
currentsong = 3;
function nextsong() {
if (currentsong = 1) {
innerHTML = currentsong.src = 'trol.mp3';
} else {
currentsong.innerHTML = currentsong.src = 'paradise.mp3';
}
}
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HigherLower</title>
</head>
<body>
<h1> welcome to my game. This game is about selecting if a number is getting higher or lower than the previous number.
Click this button to get started.</h1>
<audio id="currentsong" loop autoplay controls src="trol.mp3"></audio>
<button id="songbutton" onclick="nextsong()">next song</button>
<script src="javascript.js"></script>
</body>
</html>
여기 내 자바 스크립트 코드입니다. 미리 감사드립니다
감사합니다. 여전히 작동하지 않습니다 ... 나는 또한 내 게시물에 실수를 저지른 것을 참조하십시오. innerHTML = currentsong.src = 'trol.mp3'; 내동 HTML 없이는 currentsong.src = trol.mp3이어야합니다. –