《jquery权威指南2》学习笔记------基础函数

Math.floor(Math.random() * 7 + 1);

Math.random()  生成0和1之间的随机小数
Math.random() * 7 生成0和7之间的随机小数
Math.random() * 7 + 1生成1和8之间的随机小数
Math.floor(Math.random() * 7 + 1)生成1和8之间的随机整数,注意是整数,不是小数..
posted @ 2014-04-25 15:29  藤露  阅读(157)  评论(0编辑  收藏  举报