用jsp从1加到100

img


用JavaScript从1加到100 不能只要sum结果 要过程输出

img

<style>

 </style>
<html>
    <head>
        <title> </title>
    </head>
    <body>
       <textarea  id="content" style="width: 500;height: 500"></textarea> 
        
    </body>
</html>
    <script>
//进页面加载方法
        window.onload=function(){
            var sum=0;//申明累加值接受变量
            var result=0;//申明最后输出字符串
            var reqe=document.getElementById("content");//获取页面变量
            for(var i=1;i<=100;i++){  //循环1到100的值
            result=result+i+"+";//拼接输出数值
            sum=sum+i;//计算累加变量
            }
            result=result+"="+sum
            reqe.value=result;//页面变量赋值
            
        
        };
    </script>