この記事では、JSの方法について説明して、2つの数値間に乱数を生成するだけです。次のように、参照のために共有してください。
実行効果のスクリーンショットは次のとおりです。
完全なコードは次のとおりです。
<!doctype html public " - // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <title> generate numbers </titpinate onclick = "setrnd()" value = "生成5-10"> <script type = "text/javascript"> function rnd(min、max){return min + math.floor(math.random() *(max -min + 1);} function setrnd(){document.getelementbyid(num ")。 rnd(5,10);} </script> </body> </html>JavaScript関連のコンテンツの詳細については、このサイトのトピックをご覧ください:「JavaScript数学的操作の使用の要約」、「JavaScriptのJSON操作スキルの要約」、「JavaScriptのスイッチング特殊効果とスキルの要約」、JavaScript Search Algorithm Skillsの要約」、「Javascript Animation Spection Spection and」のサマリー「Javascript Search Algorithm Skills」スキル」、「JavaScriptデータ構造とアルゴリズムスキルの要約」および「JavaScriptトラバーサルアルゴリズムとスキルの概要」
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。