<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
div{
width:1000px;
margin:0 auto;
}
</style>
</head>
<body>
<div>
<h2 id="content">javascript能够改变html的内容。</h2>
<script>
function myFunction()
{
x=document.getElementById("content");
x.innerHTML="hello javascript!";
}
</script>
<button type="button" onclick="myFunction()">点击这里</button>
<h2>javascript设置点击改变图片</h2>
<script>
function changeimages()
{
element=document.getElementById("img")
if (element.src.match("3"))
{
element.src="images/2.jpg";
}
else{
element.src="images/3.jpg";
}
}
</script>
<img id="img" onclick="changeimages()" src="images/2.jpg" >
<h2 id="manner">javascript能够改变html的样式</h2>
<script>
function myFunction()
{
x=document.getElementById("manner");
x.style.color="red";
}
</script>
<button type="button" onclick="myFunction()">点击这里</button>
</div>
</body>
</html>
添加回答
举报
0/150
提交
取消