web1

时间:2022-02-05 23:06:48
 <!DOCTYPE html>
<html>
<head>
<title>web0923</title>
<script>
function displayDate() {
document.getElementById("date").innerHTML = Date();
}
function changePic() {
alert("Ah?");
element = document.getElementById('myImg');
element.style.color = "#ff0000";
element.height = "300";
element.width = "300";
if (element.src.match("gr+")) {
element.src = "LockScreen.jpg";
}
else {
element.src = "grass.jpg";
}
}
</script>
</head>
<body>
<h1>Title</h1>
<p>Para</p>
<div id="abc">
<p id="date"></p>
<button type="button" onclick="displayDate()">display date</button>
</div>
<div id="image">
<img id="myImg" src="grass.jpg" width="100" height="100">
<button type="button" onclick="changePic()">change picture</button>
</div>
<div>
<input id="AccountID" type="text">
<script>
function judgeNumber() {
var str = document.getElementById("AccountID").value;
if (str == "" || isNaN(str)) {
alert("This is not a number");
}
}
</script>
<button type="button" onclick="judgeNumber()">Submit</button>
</div>
</body>
</html>

学了很基础的一部分,getElementById("**控件名字**").value,一开始忘记加引号,导致怎么都出不来。。。