How to jump to an anchor / div per random button (jQuery mobile)?

岁酱吖の 提交于 2020-01-07 06:38:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!