How to jump to an anchor / div per random button (jQuery mobile)?
问题 I would like to make a random page effect in my jQuery Mobile app. Therefore I want to give the user a button to click, which jumps to / displays a random page-div on the site. thats all. 回答1: var divs = jQuery.makeArray(document.getElementsByTagName('div')); divs[Math.floor(Math.random()*(divs.size()+1))].doSomething(); 来源: https://stackoverflow.com/questions/5289615/how-to-jump-to-an-anchor-div-per-random-button-jquery-mobile