首页 > 其他 > 详细

isNaN()实例

时间:2020-01-18 09:47:33      阅读:85      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>无标题文档</title>

<script>

window.onload = function (){

    var aInp = document.getElementsByTagName(‘input‘);

    var str = ‘‘;

    aInp[1].onclick = function (){

        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>

isNaN()实例

原文:https://www.cnblogs.com/tongguilin/p/12208128.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!