```<!DOCTYPE html>
<input id="=mynum" type="text" placeholder="請輸入一個數字" value=""/> <input type="button" value="確定" onclick="G()" />
<div id="myd"></div>
<script>
function fn(num)
{
fnr1 = 0, fnr2 = 1, fnre = 0;
if (num == 0)
return 0;
else if (num == 1)
return 1;
else {
for (i = 2; i <= num; i++)
{
fnre = fnr1 + fnr2;
fnr1 = fnr2; fnr2 = fnre;
}return fnre
}
}
function G()
{
n = parseInt(document.getElementById("mynum").valueOf);
document.getElementById("myd").innerText = fn(n);
}
</script>
![圖片](http://img.ask.csdn.net/upload/201511/22/1448188720_316471.jpg)
id搞錯了,=號怎麼也放裡面去了
<input id="=mynum"
==》
<input id="mynum"