声母韵母练习 HTML 代码:随机拼音测试,图片声音反馈
以下是一个简单的 HTML 代码示例,满足您的要求:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>声母韵母练习</title>
<style>
#score {
position: fixed;
top: 10px;
right: 10px;
font-size: 18px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="score">积分: 0</div>
<h1>声母韵母练习</h1>
<button onclick="generateRandomPinyin()">下一个</button>
<h2 id="pinyin"></h2>
<img id="image" src="" alt="声音">
<script>
var score = 0;
function generateRandomPinyin() {
var initials = ['b', 'p', 'm', 'f', 'd', 't', 'n', 'l', 'g', 'k', 'h', 'j', 'q', 'x', 'zh', 'ch', 'sh', 'r', 'z', 'c', 's', 'y', 'w'];
var finals = ['a', 'o', 'e', 'i', 'u', 'ü', 'ai', 'ei', 'ui', 'ao', 'ou', 'iu', 'ie', 'üe', 'er', 'an', 'en', 'in', 'un', 'ün', 'ang', 'eng', 'ing', 'ong'];
var randomInitial = initials[Math.floor(Math.random() * initials.length)];
var randomFinal = finals[Math.floor(Math.random() * finals.length)];
var randomPinyin = randomInitial + randomFinal;
document.getElementById('pinyin').textContent = randomPinyin;
document.getElementById('image').src = 'images/' + randomPinyin + '.jpg';
}
function increaseScore() {
score += 2;
document.getElementById('score').textContent = '积分: ' + score;
}
function decreaseScore() {
score -= 1;
document.getElementById('score').textContent = '积分: ' + score;
}
generateRandomPinyin();
</script>
</body>
</html>
请注意,上述代码中使用了一个images文件夹存放声音对应的图片,图片文件名与拼音对应。您需要将对应的图片文件放入该文件夹中,并根据实际情况更改文件路径。
此外,上述代码只是一个简单的示例,仅包含基本功能。如果需要更复杂的功能或交互,您可能需要进一步完善代码。
原文地址: https://www.cveoy.top/t/topic/o0yi 著作权归作者所有。请勿转载和采集!