close
<html>
<body>
<p id="demo">My First JavaScript</p>
<button type="button" onclick="myFunc()">Try it</button>
<script>
function myFunc()
{
var x=0;
for(i=0;i<=10;i++)
{
x=x+i;
}
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
執行結果:55
全站熱搜