<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<!-- html输出 -->
<script type="text/javascript">
document.write("!!!");
document.write("???");
function myfunction()
{
x=document.getElementById("11");
x.innerHTML = "hellow";
}
</script>
<!-- 对事件的反应 -->
<button type="button" onclick="myfunction()">点我</button>
<p id="11">bibibibibib </p>
<!-- 改变html图像 -->
<script type="text/javascript">
function changeImg(){
img=document.getElementById("img");
if(img.src.match("1.jpg")){
img.src="C:/Users/石焱文/Desktop/html练习/2.jpg";
}else{
img.src="C:/Users/石焱文/Desktop/html练习/1.jpg";
}
}
</script>
<img id="img" onclick="changeImg()" src="C:/Users/石焱文/Desktop/html练习/1.jpg" width="300" height="240">
<br>
<!-- 改变html样式 -->
<script type="text/javascript">
function changeCSS(){
element=document.getElementById("button1");
element.style.color="#FF0000";
}
</script>
<button id="button1" onclick="changeCSS()" style="color: #FFFF00;">改变样式</button>
<script type="text/javascript">
function yanzheng(){
var x=document.getElementById("input1").value;
if(x==""||isNaN(x))
alert("请输入数字!");
}
</script>
<br>
<input id="input1" type="text" name="">
<button onclick="yanzheng()">验证文本</button>
</body>
</html>
Javascript学习1
最新推荐文章于 2022-04-13 16:37:59 发布