<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript"> function numb(){ var num1 = parseInt(Math.round((Math.random())*20)); document.getElementById('num1').innerHTML = num1; } </script> </head> <body onload="numb()"> <div> <span id="num1"></span> + <span id="num1"></span> = <br> </div> </body>
运行结果
为啥只出现了一个数,问题出在哪了老铁们