批改状态:合格
老师批语:



<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
<!--<script src="js/jquery-1.11.1.min.js" type="text/javascript"></script>-->
<style>
.box{
width: 500px;
height: 700px;
background-color: #efefef;
border: 1px solid lightgrey;
margin: 20px auto;
text-align: center;
color: red;
box-shadow: 2px 2px 2px #999;
}
.box ul {
margin: 0;
padding: 0;
overflow: hidden;
}
.box ul li{
list-style-type: none;
float: left;
background-color: skyblue;
margin-left: 20px;
}
.box ul li a{
display: block;
width: 100px;
height: 40px;
line-height: 40px;
color: white;
text-decoration-line: none;
}
.box ul li a:hover{
font-size: 1.2em;
background-color: coral;
}
.box .pic{
width: 450px;
height: 470px;
border: 1px solid lightgrey;
line-height: 1px;
margin: auto;
margin-top: 50px;
}
.box .pic img{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="box">
<h2>明星相册</h2>
<ul>
<li><a href="images/ym.png" title="三生三世十里桃花" onclick="changp(this);return false;">杨幂</a></li>
<li><a href="images/rb.jpg" title="三生三世十里桃花" onclick="changp(this);return false;">迪丽热巴</a></li>
<li><a href="images/zly.jpeg" title="花千骨" onclick="changp(this);return false;">赵丽颖</a></li>
<li><a href="images/fbb.jpg" title="武媚娘传奇" onclick="changp(this);return false;">范冰冰</a></li>
</ul>
<div class="pic">
<img src="images/lyf.png" alt="" id="img">
</div>
<p id="info"></p>
</div>
</body>
<script>
function changp(pic){
var picurl = pic.href
var picinfo = pic.title
var img = document.getElementById('img')
var p = document.getElementById('info')
img.src =picurl
p.innerHTML =picinfo;
}
</script>
</html>点击 "运行实例" 按钮查看在线实例
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.box{
width: 500px;
height: 220px;
background-color: #efefef;
border: 1px solid lightgrey;
margin: 20px auto;
text-align: center;
color: red;
box-shadow: 2px 2px 2px #999;
}
table{
margin: auto;
}
td{
width: 100px;
height: 30px;
padding: 5px 10px;
}
input, select{
width: 100%;
height: 100%;
border: none;
text-align: center;
}
button{
width: 100%;
height: 100%;
border: none;
background-color: skyblue;
color: white;
}
button:hover{
background-color: coral;
width: 105%;
height: 105%;
cursor: painter;
}
</style>
</head>
<body>
<div class="box">
<h2>计算器</h2>
<form>
<table>
<tr>
<td><input type="text" name="apt1" placeholder="操作数"></td>
<td>
<select name="option">
<option value="null">选择操作</option>
<option value="add">+</option>
<option value="sub">-</option>
<option value="sul">*</option>
<option value="div">/</option>
</select>
</td>
<td><input type="text" name="apt2" placeholder="操作数2"></td>
<td><button type="button">计算</button></td>
</tr>
<tr>
<td colspan="2"><h1>结果</h1></td>
<td colspan="2"><h3 id="placeholder"></h3></td>
</tr>
</table>
</form>
</div>
<script>
var apt1 = document.getElementsByName('apt1')[0]
var apt2 = document.getElementsByName('apt2')[0]
var opt = document.getElementsByName('option')[0]
var btn = document.getElementsByTagName('button')[0]
var placeholder = document.getElementById('placeholder')
btn.onclick = function () {
// alert('第一个不能为空')
if (apt1.value.length == 0) {
alert('第一个不能为空')
apt1.focus()
return false
} else if (isNaN(apt1.value)) {
alert('非法数据')
} else if (apt2.value.length == 0) {
alert('第二个不能为空')
apt2.focus()
return false
} else if (isNaN(apt2.value)) {
alert('非法数据')
} else {
var data1 = parseFloat(apt1.value)
var data2 = parseFloat(apt2.value)
}
var option = opt.value
var temp = 0
switch (option) {
case 'null':
alert('qing')
opt.focus()
return false
case 'add':
flag = '+'
temp = data1 + data2
break
case 'sub':
flag = '-'
temp = data1 - data2
break
case 'mul':
flag = '*'
temp = data1 * data2
break
case 'div':
flag = '/'
if (data2 == 0) {
alert('除数不能为0')
return false
} else {
temp = data1 / data2
}
break
}
placeholder.innerHTML = data1 +''+flag+''+data2+'='+temp
}
</script>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号