/
13.html
34 lines (32 loc) · 1015 Bytes
/
13.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>添加数据 | cnzsb</title>
<script type="text/javascript" src="../public/js/analytics.js"></script>
</head>
<body>
<label>请输入上海今天温度:<input id="aqi-input" type="text"></label>
<button id="button">确认填写</button>
<div>您输入的值是:<span id="aqi-display">尚无录入</span></div>
<script type="text/javascript">
(function() {
var aqiInput = document.getElementById('aqi-input'),
aqiDisplay = document.getElementById('aqi-display'),
button = document.getElementById('button');
// 为空不操作
button.onclick = function () {
if (aqiInput.value != '') {
aqiDisplay.innerHTML = aqiInput.value.trim();
aqiInput.value = '';
}
};
// 去掉前后空格,兼容低版本IE
String.prototype.trim = function () {
return this.replace(/(^\s*)|(\s*$)/g, '');
};
})();
</script>
</body>
</html>