App下载
实例代码( Tip: 登录后体验更佳 )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool(w3cschool.cn)</title>
</head>
<body>
<p id="demo"></p>
<button onclick="myFunction()"></button>
<script>
function myFunction(){
var a=Math.abs(7.25);
var b=Math.abs(-7.25);
var c=Math.abs(null);
var d=Math.abs("Hello");
var e=Math.abs(2+3);
var x=document.getElementById("demo");
x.innerHTML=a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e;
}
</script>
</body>
</html>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
运行结果