function sj() { //x上限,y下限 var x = 2000; var y = 1800; var rand = parseInt(Math.random() * (x - y + 1) + y); console.log(rand); } $('#date').click(function() { sj(); });