JS循環

1.JS for循環

<html>
<head>
<script type="text/javascript">
function product(a,b)
{
return a*b
}
</script>
</head>

<body>
<script type="text/javascript">
document.write(product(6,5))
</script>

<p>body 部分中的腳本調用一個帶有兩個參數(6 和 5)的函數。</p>
<p>該函數會返回這兩個參數的乘積。</p>

</body>
</html>
 

2.循環產生html標籤

<html>
<body>

<script type="text/javascript">
for (i = 1; i <= 6; i++)
{
document.write("<h" + i + ">這是標題 " + i)
document.write("</h" + i + ">")
}
</script>

</body>
</html>
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章