点击按钮
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button onclick="alert('hello World')">点击按钮</button>
</body>
</html>
水仙花
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
var a, b, c;
for (var i = 100; i < 1000; ++i) {
a = i % 10;
b = ((i / 10) % 10);
b = parseInt(b);
c = i / 100;
c = parseInt(c);
if (i == a * a * a + b * b * b + c * c * c)
document.write('水仙花数:'+i + "<br />");
}
</script>
</head>
<body>
</body>
</html>
函数
function alertInfo(msg) {
alert(msg);
}
function calculate(x, c, y) {
if ('+' == c) {
return x+y;
}
if ('-' == c) {
return x-y;
}
if ('*' == c) {
return x*y;
}
if ('/' == c) {
return x/y;
}
}
alertInfo(calculate(1,'+',100));