JavaScript Tutorial/Math/cos
Версия от 18:52, 25 мая 2010; (обсуждение)
Math.cos()
The cos() method calculates the cosine of a number.
It returns a numeric value between -1 and 1, representing the cosine of an angle.
<html>
<body>
<script language="JavaScript">
<!--
function doMath(){
var inputNum=document.form1.input.value;
var result = Math.cos(inputNum);
document.form1.answer.value = result;
}
-->
</script>
<form name=form1>
This exanple calculates the cosine of the entered number.
<br><br>
Enter First Number:
<input type="text" name="input" size=10>
<input type="button" value="Calculate" onClick="doMath()">
<br>
The cosine is:
<input type="text" name="answer" size=10>
</form>
</body>
</html>