您的位置:首页 > Web前端 > JavaScript

有关javascript 里的Math的使用.

2014-07-29 21:10 295 查看
<!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>
<title>Untitled Page</title>

<script type="text/javascript">
///计算三角函数的的
function resule() {
var longBorder = new Number(document.getElementById("longBorder").value);

var shortBorder = new Number(document.getElementById("shortBorder").value);

var resuleConValue = new Number();

resuleConValue = Math.atan2(shortBorder, longBorder);
angle = resuleConValue * (180 / Math.PI);

document.getElementById("resultCon").value = angle
}

</script>

</head>
<body>
<p>
长边:<input type="text" id="longBorder" />
</p>
<p>
短边:<input type="text" id="shortBorder" />
</p>
<p>
结果:<input type="text" id="resultCon" />
</p>
<input type="button" value="计算" onclick="resule();" />
</body>
</html>
document.getElementById("longBorder").value
才是获取文本框里面的值..

而document.getElementById("longBorder")
是获取值里的对象.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: