第一题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button onclick="alert('12121')">按钮</button>
</body>
</html>
第二题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script type="text/javascript">
var i,a,b,c;
for (i = 100; i < 1000; i++) {
a=parseInt(i/100);
b=parseInt((i-a*100)/10);
c=parseInt(i-a*100-b*10);
if( a*a*a+b*b*b+c*c*c == i){
document.write(i+"是水仙花数"+"<br>");
}
}
</script>
</body>
</html>
第三题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
请输入第一个数字:<input type="text" id="x"/><br/>
请输入第一个数字:<input type="text" id="y"/><br/>
请输入运算符号 :<input type="text" id="z" placeholder="+ - * /"/><br/>
<button onclick="three()">点击计算</button>
</head>
<body>
<script>
function three() {
var x=parseInt(document.getElementById('x').value);
var y=parseInt(document.getElementById('y').value);
var z=document.getElementById('z').value;
var sum=0;
if(z=="+"){
sum=x+y;
}else if(z=="-"){
sum=x-y;
}else if(z=="*"){
sum=x*y;
}else if(z=="/"){
sum=x/y;
}
alert(sum);
}
</script>
</body>
</html>
Week2Day4
最新推荐文章于 2023-03-21 18:59:29 发布