<!DOCTYPE HTML>html
<html>ide
<head>ui
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">spa
<title>無標題文檔</title>htm
<script>ip
window.onload = function (){utf-8
var aInp = document.getElementsByTagName('input');文檔
var str = '';字符串
aInp[1].onclick = function (){get
str = aInp[0].value;
// HTML 中拿到的內容,類型都是字符串
// alert( typeof str );
if( isNaN(str) ){
alert( str + '不是數字' );
}else{
alert( str + '是數字' );
}
};
};
</script>
</head>
<body>
<input type="text" />
<input type="button" value="判斷輸入值是否是數字" />
</body>
</html>