用html语言写一段随机抽取人员的代码
<html>
<head>
<script>
function randomSelection() {
var names = ["张三", "李四", "王五", "赵六", "钱七", "孙八"];
var randomIndex = Math.floor(Math.random() * names.length);
var selectedPerson = names[randomIndex];
document.getElementById("result").innerHTML = "随机抽取的人员是:" + selectedPerson;
}
</script>
</head>
<body>
<button onclick="randomSelection()">随机抽取人员</button>
<p id="result"></p>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/h2ut 著作权归作者所有。请勿转载和采集!