您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 玉树分类信息网,免费分类信息发布

讲解数学对象Math相关内容

2024/3/10 13:45:56发布12次查看
数学对象math
一、方法
1》  math.min(参数1,参数2,参数3) 求出参数中最小值
2》  math.max(参数1,参数2,参数3) 求出参数中最大值
3》  math.floor()  舍掉小数得到整数
4》  math.ceil()  有小数点就进1取整(舍去小数部分,得到整数部分+1)
5》  math.abs()  获取绝对值
6》  math.sqrt()  开平方的
7》  math.random()  随机数 (范围0-1之间)
8》  math.round() 四舍五入
//数学对象math/*var min = math.min(3,5,6,1);//求出参数中最小值document.write(min)var max = math.max(33,44,88,29);//求出参数中最大值document.write(max)*//*var num1 = 3.1415926;document.write(math.floor(num1));//舍掉小数得到整数document.write(parseint(num1))document.write(math.ceil(num1));//有小数点就进1取整(舍去小数部分,得到整数部分+1)var num1= -5document.write(math.abs(num1));//取绝对值var num2 = 64document.write(math.sqrt(num2));//开平方*///document.write(math.random());//随机数 (范围0-1之间)//案例 范围是0-5之间的随机数//document.write(math.floor(math.random()*5));/*var num = 3.5document.write(math.round(num)); //四舍五入*///案例 表单随机验证码var span = document.getelementbyid('span'), btn = document.getelementbyid('btn'), username = document.getelementbyid('username'), userpwd = document.getelementbyid('userpwd'), yzm = document.getelementbyid('yzm');var str = 'abcdefghigklmnopqrstuvwxyz1234567890';var str1 = '';for(var i = 0; i < 4 ; i ++ ){ str1 += str[math.floor(math.random()*str.length)]}span.innerhtml =str1;// math.floor(math.random()*9000)+1000 ;//innerhtml 往元素中 写入html代码//document.write( math.floor(math.random()*9000)+1000 );btn.onclick = function(){ if(username.value == 'admin'){ if(userpwd.value == 'admin'){ if(yzm.value == span.innerhtml){ location.href = 'login.html' }else{ alert('验证码不对') } }else{ alert('密码不能为空') } }else{ alert('用户名不能为空') }}
<!doctype html><html><head><meta charset="utf-8"><title></title></head><body><!--案例用户名密码验证码===》数字4位数的随机 (混合 数字 字母 4位数随机)以上所有内容都完成 都为true ====>登录 跳转页面--><form action="" method="post">用户名 <input type="text" id="username"/><br />密码 <input type="password" id="userpwd"/><br />验证码 <input type="" name="" id="yzm" value="" /><span id='span'></span><br /><input type="button" name="" id="btn" value="登录" /><br /></form><script src="script.js"></script></body></html>
本文讲解了数学对象math相关内容,更多相关内容请关注。
相关推荐:
关于js和jsp的区别讲解
javascript中的this的讲解
关于微信小程序上传word、txt、excel、ppt等文件的详解
以上就是讲解数学对象math相关内容的详细内容。
玉树分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录