0
How can I convert a variable to an integer in _
in html but not in html5
2 Réponses
0
use parseInt
e.g var a = 45
as numbers are displayed in double precision so while document.write(a) it will.display as 45.00 so to convert to int just do these
var a = parseInt(45) will display it as int 45
hope it helps
cheers .. !
0
When will the number be sipalyed as 45.00 as if declared in a function it will just show two digits?
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button onclick="myFunction()">Go!</button>
<p id="show"></p>
<script>
function myFunction() {
var num = 45
document.getElementById("show").innerHTML = num;
}
</script>
</body>
</html>