当第一页加载时,我希望用户遇到所有音乐,但如果他从 RadioButton 中选择一个列表,我只想要该列表中的音乐,但 javascript 功能不起作用。让我补充一点,我通常不了解 JavaScript,但我需要使用它。<div style = "margin-top : 100px;"class = "container"> {% for table in tables %} <input type="radio" name="list1" onclick="mL('{{table}}')"> {{table}} {% endfor %} <div align="center"> <audio class="my_audio" controls="controls" autoplay="autoplay" style="width:500px;"></audio> <ul> {% for table in tables %} {% for music in musics %} <li style="list-style-type:None"> <a id="{{table}}" href="javascript:void(0);" onclick="playSong('{{music}}')">{{music}}</a> </li> {% endfor %} {% endfor %} {% for music in musics %} <li style="list-style-type:None"> <a id="default" href="javascript:void(0);" onclick="playSong('{{music}}')">{{music}}</a> </li> {% endfor %} </ul> </div> </div><script> function mL(x) { {% for table in tables %} if (x=={{table}}) document.getElementById("{{table}}").style.display="block"; document.getElementById("default").style.display="none"; {% endfor %} else document.getElementById("{{table}}").style.display="none"; document.getElementById("default").style.display="block"; return; } </script>
添加回答
举报
0/150
提交
取消