标签: javascript jquery
有人得到了一个很好的代码片段吗?
答案 0 :(得分:5)
怎么样:
//generate random number with maximum size of the number of p elements var elems = $('p'); var rand = Math.floor(Math.random() * elems.length); alert(elems.eq(rand).text());