<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title><script>window.onload = function (){ function fn1(){ var str; str = prompt("請輸入你的成績"); if(str >= 80){ document.write("不錯很牛逼"); }else{ document.write("加油!"); } }; }</script></head><body><input type="button" value="點擊我,驗證你的成績是否合格!" onclick="fn1()" /></body></html>上面這個函數,我在按鈕中添加點擊事件的時候,顯示fn1 ?未定義,這是怎么回事啊 ?
關于JS中調用函數顯示未定義
慕粉1470498377
2016-09-20 11:05:15