P粉1949190822023-09-03 00:57:33
let dataList =["句子1","句子2","句子3","句子4"] let div = document.getElementById('asd') document.getElementsByTagName("button")[0].addEventListener("click",myFunc) function myFunc(){ let x = parseInt(Math.random()* dataList.length ) div.innerHTML = dataList[x] }
<button>点击我</button> <div id='asd'></div>