The tan()
method returns a number
that represents the tangent of an angle.
tan() |
Yes | Yes | Yes | Yes | Yes |
Math.tan(x);
Parameter | Description |
---|---|
x | Required. A number representing an angle in radians |
A Number representing the tangent of an angle.
The following code shows how to calculates the tangent of a number.
<html>
<body>
<script language="JavaScript">
function doMath() {<!--from ww w . java 2 s . c om-->
var inputNum1 = document.form1.input1.value;
var result = Math.tan(inputNum1);
document.form1.answer.value = result;
}
</script>
<form name=form1>
This example calculates the tanget of the entered number. <br>
<br> Enter Number: <input type="text" name="input1" size=10>
<input type="button" value="Calculate" onClick='doMath()'> <br>
The tangent is: <input type="text" name="answer" size=20>
</form>
</body>
</html>