JSは初めてです。JSを入れdocument.getElementById
て、その要素をIDに入れようとしましたp
が、ボタンをクリックしても何も表示されません。私はここで何が間違っているのですか?どんな助けでも大歓迎です。ありがとうございました!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GRL Example</title>
<script>
function class_roll() {
// Car Classes
var classes = ["B", "A", "S", "R3", "R2", "R1"],
classToUse = classes[Math.floor(Math.random() * classes.length)];
var elemClass = document.getElementById("croll");
}
function track_roll() {
// Tracks
var tracks = ["Clear Springs Circuit", "Festival North Circuit", "Beaumont Circuit", "Finley Dam Circuit", "Gladstone Circuit", "Clifton Valley Trail", "Gladstone Trail"],
trackToUse = tracks[Math.floor(Math.random() * tracks.length)];
var elemTrack = document.getElementById("troll");
}
</script>
</head>
<body>
<p id="croll">Some text here</p>
<button onclick="class_roll();">Class Roll</button>
<p id="troll">Some text here</p>
<button onclick="track_troll;">Track Roll</button>
</body>
</html>