Dav*_*cio -3 javascript random percentage
所以我有这段代码,它为我提供了一些图像的顶部和左侧属性的随机数。
var random1 = Math.ceil(Math.random() * 500);
var random2 = Math.ceil(Math.random() * 500);
$(document).ready(function () {
$('#randomp').css('top', random1);
$('#randomp').css('left', random2);
});
Run Code Online (Sandbox Code Playgroud)
问题是我更愿意随机化 1 到 100% 之间的数字。那可能吗?